Module 11: Creating Output with ODS and Exporting Data From SAS Flashcards
What are the 3 main methods of exporting data from SAS programaically?
1) Using ODS
2) In a PROC EXPORT step
3) In a DATA step, using PUT statements
Write the general syntax for PROC EXPORT.
proc export data=dataset;
outfile = file-path\file-name.file-type
dbms = deliminator-type
replace;
run;
In PROC EXPORT, how do you specify the file extension?
Put the file extension that you want to use in the file name.
Ex. file-path*file-name*.csv
This example specifics a csv is to be explorted
Can also do xlsx, dta, txt, etc.
In PROC EXPORT, what does the dbms satement do?
Specifies the type of delimiter to use.
T/F: Using the dbms option takes precedence over the file extension when exporting data.
True: Will override the delimiter type normally used in the file extension.
T/F: Formats are not exported for delimited files in PROC EXPORT.
False: Formats are exported
Explain the lines in the following code.
1) data -null-;
2) set one;
3) file ‘file-path-and-extension’;
4) if -n-=1 then put @01 “EMPID” @10 “GENDER” @20 “RACE;
5) put @01 empid @10 gender @20 race;
run;
Note: - = underscore
This is for tab delimited files
1)Creates an automatic null dataset and is used so no additional datasets are created, only external file
2)Using data from one
3)Creates new file
4)Puts headers for data
5)Creating variable columns starting at line 1, 10, and 20
Note: make sure columns are ‘wide’ enough for header and data
Explain the lines in the following code.
1) data -null-; set one;
2) file ‘file-path-and-extension’ dlm = ‘,’;
3) if -n- = 1 then put ‘EMPID’ ‘,’ ‘GENDER’ ‘,’ ‘RACE’ ‘,’;
4) put empid gender race;
run;
Note: - = underscore
This is for comma delimited files
1)Creates automatic null dataset using data from one
2)Creates new file
3)Specifies row 1 as header row, seperated variables by commas
4)specifies the order of data for columns
T/F: HTML is the default destination for SAS Studio, the SAS windowing environment, and UNIX.
True
Why do we use the ODS TRACE statement?
Helps us find the names of output obejects that can then be used as regular SAS datasets.
How do you turn ODS TRACE on and off?
ods trace on;
ods trace off;
Write the general code to specify the datasets you want SAS to create in ODS.
ods output output-object = dataset-name;
Where do you put the ODS OUTPUT statement in SAS?
Ex. proc glm data=one;
by flsa;
class eeogroup;
model = specified-model;
ods output output-object = dataset;
run;
After proc statement, but before next run, proc , or data statement
Explain the lines in the following code.
1) ods csv file= ‘file-path\filename.csv’;
2) proc print data=allresults noobs;
3) title1 ‘model output’;
run;
4) ods csv close;
1) creates exporting path and filename, specifying its a csv
2) specifies what to put in new file, excluding observation numbers
3) Creates a title for file
4) closes csv file.
T/F: ODS output is created in the windowing mode.
False: Writes in an output window