*********************************************************************** Filename: mergecode_c.txt Program Function: Example SAS steps to merge an NHANES 2003-2004 data file with the NHANES 2003-2004 Demographics data. This uses the Early Childhood dataset as an example. The merge procedure is the same for Exam, Lab, and Questionnaire datasets. Written By: CDC/NCHS/DHES Date: October 2005 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" (suggested folder names). 2. In a suitable web browser, go to http://www.cdc.gov/nchs/about/major/nhanes/NHANES03_04.htm 3. Find the entry for "Early Childhood" on the "Questionnaire Files" page and click on "Data" link. Save this file to the "C:\My Files\Temp" folder. 4. Return to the web browser. Find the "Demographics" link under the "Demographics File" area and click on it. Save this file to the "C:\My Files\Temp" folder. 5. Start your version of the SAS program. 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 ECQ_DEMO which contains the early childhood data merged with the demographics variables RIDAGEYR and RIAGENDR from demo_c.xpt. ECQ_DEMO will be saved in the SAS data library titled "C:\My Files\Temp\NHANES". ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LIBNAME DM XPORT 'C:\My Files\Temp\demo_c.xpt'; LIBNAME QX XPORT 'C:\My Files\Temp\ecq_c.xpt'; LIBNAME OUT 'C:\My Files\Temp\NHANES'; DATA OUT.ECQ_DEMO; MERGE DM.DEMO_C (KEEP=SEQN RIDAGEYR RIAGENDR) QX.ECQ_C (IN=A); BY SEQN; IF A; RUN;