CS计算机代考程序代写 MET MA 603: SAS Programming and Applications

MET MA 603: SAS Programming and Applications

MET MA 603:
SAS Programming and Applications

Exporting Data

1

1

Exporting Data
Sometimes results or datasets need to be stored or communicated in other forms or file types. There are several possible motivations for this:
Not everyone knows how to use SAS.
Not everyone has access to SAS.
There are special programs designed for displaying results, which can produce nicer-looking reports than SAS.
Text files are usually the most efficient way to store and exchange large datasets.
The methods for exporting data each have an analog among the methods for importing data:
Export Wizard ~ Import Wizard
Proc Export ~ Proc Import
Data Step Export ~ Data Step Import

2

2

The Export Wizard
The Export Wizard is a point-and-click tool built into SAS with the purpose of creating a file based on a SAS dataset.
The Wizard is initiated by clicking File >> Export Data.
The Wizard prompts for various pieces of information about the SAS dataset to be exported and the external file to be created. These options are self-explanatory.
Using the Wizard generates SAS code, which can be saved for re-use or modification.

3

3

Practice Export Wizard
Use the Export Wizard to create a text file based on the SAS dataset Heights.sas7bdat. Save the generated code.

4

4

The Export Procedure
The Export Procedure is a procedure that creates an external file based on a SAS dataset. In the Proc Export statement, the outfile specifies the path and name of the external file to be created.
The default delimiter for .txt files is the tab.
The optional statements in the Export Procedure are similar to the optional statements that can be used with the Import Procedure.
proc export data = numbers
outfile = “C:\Users\dgovonlu\Desktop\numbers.txt” replace ;
delimiter = “ “ ;
putnames = No ;
run;

5

5

Exporting to a Delimited File
Use the Export Procedure to create a text file based on the SAS dataset Accounts.sas7bdat. Use the underscore character (_) as a delimiter. Include the variables names in the external file.

6

6

Exporting with the Data Step
The Export Wizard and Export Procedure are sufficient for most tasks, but both do not allow for precise control over the layout of the data in the external file.
The Data Step can be used to create external files with almost any type of layout.
A common example of needing to use the Data Step to create an external file is when large datasets are being transferred from one party to another via text file.
data _null_;
file “C:\Users\govonlu\Desktop\Exported Data\numbers2.txt”;
set work.numbers;
put num @10 num_cumul comma8.2;
run;

7

7

Exporting to a Fixed-Width File
Use the Data Step to create a text file based on the SAS dataset Heights.sas7bdat. The text file should have a layout similar to the one below (exact column positions do not matter):

8

8

Readings

Textbook sections (5th edition) 10.2, 10.3, 10.5
Textbook sections (6th edition) 10.2, 10.6

9

9

/docProps/thumbnail.jpeg