Here are the steps to appending NHANES data in SAS:
After sorting the data files, you can continue merging the data using the merge statement. Remember that you will always merge on a unique identifier — in this case, the SEQN variable. This is demonstrated in the table below Step 3.
After you have merged the data files, it is advisable that you check the contents again to make sure that the files merged correctly. Use the proc contents procedure to list all variable names and labels; use the proc means procedure to check the number of observations for each variable as well as missing, minimum, and maximum values.
Statements | Explanation |
---|---|
data =DEMO_4yr;
by SEQN; |
Use the proc sort procedure and by statement to sort the 4-year demographic data by SEQN. |
data =BPX_4yr;
by SEQN; |
Use the proc sort procedure and by statement to sort the 4-year blood pressure examination data by SEQN. |
data =BPQ_4yr;
by SEQN; |
Use the proc sort procedure and by statement to sort the 4-year blood pressure questionnaire data by SEQN. |
data =MCQ_4yr;
by SEQN; |
Use the proc sort procedure and by statement to sort the 4-year medical conditions questionnaire data by SEQN. |
data =LAB13_4yr;
by SEQN; |
Use the proc sort procedure and by statement to sort the 4-year laboratory data by SEQN. |
DEMO_BP; | Use the data step to name the new dataset that will contain the merged files (DEMO_BP). |
merge
DEMO_4yr |
Use the merge statement to merge data from the five data files by their linking variable - SEQN. |
data =DEMO_BP varnum ; | Use the proc contents procedure to list contents of the DEMO_BP data — the new merged dataset. Use the varnum option to order the listed variables according to their positions in the dataset. |
data =DEMO_BP N Nmiss min max maxdec = 2 ; | Use the proc means procedure to show the mean, number of missing values, minimum and maximum values for the variables in the merged dataset (DEMO_BP). |
Highlighted results of this program: