*********************************************************************** Filename: mergecode_d.txt Program Function: Example SAS steps to merge an NHANES 2005-2006 data file with the NHANES 2005-2006 Demographics data. This uses the Blood Pressure and Cholesterol dataset as an example. The merge procedure is the same for Exam, Lab, and Questionnaire datasets. Written By: CDC/CCHIS/NCHS/DHNES Date: November 2007 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 the NHANES Web Page and click on "Data Sets and Related Documentation" and the click on "NHANES 2005-2006". 3. Find the entry for "Blook Pressure and Cholestrerol" on the "Questionnaire Files" page and right-click on "Data" link. Select "Save Target AS" and save this file to the "C:\My Files\Temp" folder. 4. Return to the web browser. Find the "Demographics" link on the "Demographics File" page and right-click on "Data" link. Select "Save Target AS" and 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 BPQ_DEMO which contains the early childhood data merged with the demographics variables RIDAGEYR and RIAGENDR from demo_d.xpt. BPQ_DEMO will be saved in the SAS data library titled "C:\My Files\Temp\NHANES". ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LIBNAME DM XPORT 'C:\My Files\Temp\demo_d.xpt'; LIBNAME QX XPORT 'C:\My Files\Temp\bpq_d.xpt'; LIBNAME OUT 'C:\My Files\Temp\NHANES'; DATA OUT.BPQ_DEMO; MERGE DM.DEMO_D (KEEP=SEQN RIDAGEYR RIAGENDR) QX.BPQ_D (IN=A); BY SEQN; IF A; RUN;