Task 2: Extract and Copy NHANES Data Files to Permanent Libraries

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


Step 1: Assign libnames

In your SAS program, you will need to first assign a libname to the place where you would like the permanent file to be and the transport file you downloaded in Task 2.

Assign libnames
Statements Explanation

libname NHANES "C:\NHANES\";

Assigns the libname NH to the C:\NHANES\ folder. This is where the new dataset will be saved. Remember to surround the pathname in quotation marks.

libname XP xport "C:\NHANES\TEMP\demo.xpt";

Assigns the libname XP to the SAS transport file, demo.xpt, stored in the TEMP folder. The xport statement tells SAS to extract the data from the transport file using the XPORT engine.


Step 2: Copy to permanent library

Use proc copy to copy the extracted data file to a permanent SAS library.


proc copy
Statements Explanation

proc copy in=XP out=NHANES;

Copies the extracted dataset from the transport file to the C:\NHANES\DATA folder.


Step 3: Check results

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


close window icon Close Window to return to module page.