***********************************************************************
Program Function:

  SAS steps and example code to merge an NHANES 2007-2008 data file 
  with the NHANES 2007-2008 Demographics data. This example uses the 
  "Blood Pressure and Cholesterol" Questionnaire dataset.

  This merge procedure applies to Exam, Lab, and Questionnaire 
  datasets.

Written By:

  CDC/OSELS/NCHS/DHNES

Steps:

  Please complete the following steps to download the data file from 
  the NHANES website and merge it with select variables from the 
  demographics file: 

  1. Create two folders on your computer named "C:\CDC" and 
     "C:\CDC\NHANES" (suggested folder names).

  2. In a web browser, navigate to the NHANES web page, click 
     "Questionnaires, Data Sets and Related Documentation", click 
     "NHANES 2007-2008".

  3. Click "Questionnaire Data", locate the entry for "Blook Pressure 
     & Cholestrerol", right-click the associated "Data File" link, 
     choose "Save Target As", and then save the file to "C:\CDC" 
     folder.

  4. Click "Demographics Data", right-click the associated "Data File" 
     link, choose "Save Target As", and then save the file to "C:\CDC" 
     folder.

  5. Launch your SAS application. Copy and paste the SAS program below 
     to the SAS editor window, then click the Run icon on the SAS 
     toolbar. This code creates a file named BPQ_DEMO that contains 
     blood pressure data merged with the demographics variables 
     RIDAGEYR and RIAGENDR from demo_e.xpt. BPQ_DEMO will be saved in 
     the SAS data library named "C:\CDC\NHANES". 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LIBNAME DM XPORT 'C:\CDC\demo_e.xpt';
LIBNAME QX XPORT 'C:\CDC\bpq_e.xpt';
LIBNAME OUT 'C:\CDC\NHANES';

DATA OUT.BPQ_DEMO;
   MERGE DM.DEMO_e (KEEP=SEQN RIDAGEYR RIAGENDR) 
         QX.BPQ_e (IN=A);
   BY SEQN;
   IF A;
   RUN;