Task 3: How to Run the SAS Code to Create the SAS Data Files in a Permanent Library

There are four steps to extracting a SAS transport file and copying it to a permanent library:

Step 1 Open SAS Code

Open SAS and navigate to your TEMP folder where you downloaded the SAS code for the adult, youth, lab and exam data. Open exam.sas. This is the file you will modify to extract the data and create permanent libraries. In this example, you will be working with the exam data, and you will need to repeat these steps for the other three files.

 

Step 2 Modify filenames and assign libnames

In your SAS code file, you will need to modify the pathway for the Filename where you downloaded the data file and assign a libname to the place where you'd like the permanent file to be.
 

Assign libnames
Statements Explanation
Filename In "C:\NHANES III\TEMP\EXAM.DAT" LRECL=6235;

Assigns the filename " In" and identifies the path for the data file you will read into the SAS code as the C:\NHANES III\TEMP folder. This is where you downloaded and inflated the EXAM.DAT out of the EXAM.EXE file from the NHANES website. Remember to modify the pathname according to your actual location and surround the pathname in quotation marks. Leave the LRECL statement intact as this identifies the size of the file being read into the program.

libname NH3 "C:\NHANES III\DATA";

Assigns the libname " NH3" and identifies the path for the SAS data file you will create as C:\NHANES III\DATA.  Remember to modify the pathname according to your actual location and surround the pathname in quotation marks.

 

Step 3 Output to permanent library

You will need to modify the Data step commands to identify the correct infiles and output files. Then you will need to append a RUN command at the bottom of the SAS code.

Code to Output to Permanent Library
Statements Explanation
Data NH3.exam;

This modification assigns a name to the SAS data file you will output to the library and identifies the libname command "NH3" which specifies the location as the C:\NHANES III\DATA folder.

Infile In missover;

This identifies the filename command " In" which is the source of your input data file. MISSOVER prevents the input pointer from going to the next record if it fails to find values in the current line for all variables that are listed in the INPUT statement.

Run;

This command in PC SAS is necessary to get the SAS code to run and complete the task.

 

Step 4 Check results

To check the results of your program, open Windows Explorer and go to your C:\NHANES III\DATA folder. You should now see exam.sas7bdat in the folder. You now have the examination SAS dataset.

The activities for this task are to download, create and save the data files you'll need for your analysis and to download the related documentation for the other three components of your analysis — adult questionnaire, laboratory data, and youth questionnaire data to ensure accurate sample size counts for statistical analyses.

 

 

 

close window icon Close Window.