*********************************************************************** Filename: ffqmergecode_c.txt Program Function: Example SAS steps to merge the NHANES 2003-2004 FFQDC_C data file with the Varlook and Foodlook lookup tables. Written By: CDC/NCHS/DHES Date: February 2008 Notes: This program assumes you have already converted the FFQDC_C, FOODLOOK, and VARLOOK SAS Transport Files to SAS Datasets in a folder entitled 'C:\My Files\Temp'. Once you have done this, executing the SAS code below will create a merged dataset called 'merged' in the same folder. *********************************************************************** libname lib 'C:\My Files\Temp'; proc sort data=lib.ffqdc_c; by FFQ_VAR; run; data temp_merge; merge lib.ffqdc_c(in=a) lib.varlook(rename=(VALUE=VAR_VALUE) in=b); by FFQ_VAR; if a; run; proc sort data=temp_merge; by FFQ_FOOD; run; data lib.merged; merge temp_merge(in=a) lib.foodlook(rename=(VALUE=FOOD_VALUE) in=b); by FFQ_FOOD; if a; run; proc sort data=lib.merged; by SEQN FFQ_VAR FFQ_FOOD; run;