*********************************************************************** Program Function Example SAS steps to merge an NHANES 1999-2000 data file with some of the NHANES 1999-2000 Demographics data. This uses the lab 13 (Total Cholesterol) dataset as an example. Written By CDC/NCHS/DHES Date August 27, 2002 Notes Please follow these steps to download the correct file from the NHANES Website and then merge the data file with selected variables from the demographics file: 1. Create two folders on your PC titled "C:\My Files\Temp" and "C:\My Files\Temp\NHANES". 2. In a suitable web browser, go to /nchs/about/major/nhanes/NHANES99_00.htm 3. Find the "Lab 13 Total Cholesterol" link under the "Laboratory Files" area and click on it. If prompted for a location to download the file to, specify "C:\My Files\Temp". This will start downloading a self-extracting file, "lab13.exe" to your machine. Execute this file once the download is complete. After executing this file a new window will appear on your screen asking where to extract files to. Specify "C:\My Files\Temp". Then hit the "extract" button at the bottom left of this window. This action will result in three files in "C:\My Files\Temp": LAB13.pdf (codebook), LAB13.xpt (SAS transport file), and LAB13DOC.pdf (Lab 13 (Total Cholesterol) documentation). 4. Return to the web browser. Find the "Demographics" link under the "Demographics File" area and click on it. If prompted for a location to download the file to, specify "C:\My Files\Temp". This will start downloading a self-extracting file, "demo.exe" to your machine. Execute this file once the download is complete. After executing this file a new window will appear on your screen asking where to extract files to. Specify "C:\My Files\Temp". Then hit the "extract" button at the bottom left of this window. This action will result in three files in "C:\My Files\Temp": DEMO.pdf (codebook), DEMO.xpt (SAS transport file), and DEMODOC.pdf (Demographics documentation). 5. Start your version of the SAS program. Next copy and paste the SAS program provided below to the SAS program editor window, then click on the Run icon on your SAS toolbar. This code will create LAB13A which contains the early childhood data merged with the demographics variables RIDAGEYR and RIAGENDR from DEMO.xpt. LAB13A will be saved in a permanent SAS data library, titled "C:\My Files\Temp\NHANES". 6. After running the SAS program, you may safely delete the files lab13.exe, demo.exe, LAB13.xpt and DEMO.xpt. Do not delete the other files in "C:\My Files\Temp" and "C:\My Files\Temp\NHANES", these are your documentation, codebook and data files. Note: The folder names in this example are suggestions. Change them if you wish. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LIBNAME L XPORT 'C:\My Files\Temp\LAB13.xpt'; LIBNAME D XPORT 'C:\My Files\Temp\DEMO.xpt'; LIBNAME P 'C:\My Files\Temp\NHANES'; DATA P.LAB13A; MERGE D.DEMO (KEEP=SEQN RIDAGEYR RIAGENDR) L.LAB13 (IN=A); BY SEQN; IF A; RUN;