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

  SAS steps and example code to merge an NHANES 2005-2006 data file 
  with the NHANES 2005-2006 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 2005-2006".

  3. Click "Questionnaire Data", locate the entry for "Blood Pressure 
     & Cholesterol", 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 demographic variables 
     RIDAGEYR and RIAGENDR from demo_d.xpt. BPQ_DEMO will be saved in 
     the SAS data library named "C:\CDC\NHANES". 

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

LIBNAME DM XPORT 'C:\CDC\demo_d.xpt';
LIBNAME QX XPORT 'C:\CDC\bpq_d.xpt';
LIBNAME OUT 'C:\CDC\NHANES';

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