Task 1: How to Keep NHANES I Data

Here are the steps to keep NHANES I data:

 

Step 1 Keep variables

Because you are interested only in a subset of the variables, you can use the keep option statement to select relevant variables. No output is associated with this procedure, so you will need to check the SAS log file to make sure that the procedure was completed successfully. Additionally, you can use SAS Explorer to see that the new datasets (Anthro, Biochem, Exam, AdultHistory, GenMedical) are in your WORK library. 

 

Program to Directly Keep Datasets
Statements Explanation
data biochem;

Use the data step to create a dataset for your biochemistry data (biochem).

set nh1.biochem;

Use the set statement to bring in the biochemistry file.

 
keep seqn N1LB0237;

Use the keep statement to select the variables of interest.

Info iconIMPORTANT NOTE

Notice that in the keep statement, a variable named "seqn" is included. SEQN stands for sequence number and should be included whenever datasets are appended. SEQN is a unique identifier for each observation (participant) in NHANES. Every time you extract variables from an NHANES III data file, you should include the SEQN variable in your selection. Failing to do so will lead to problems if you want to sort or merge your data files at a later time. See Keep & Merge Module Task 2 for more information on Merging.

data exam;

Use the data step to create a dataset for your examination data (exam).

set nh1.exam;

Use the set statement to bring in the examination file.

keep seqn N1ME0228 N1ME0231 N1ME0718 N1ME0721;

 

Use the keep statement to select the variables of interest.

data adulthistory;

Use the data step to create a dataset for your adult history questionnaire data (AdultHistory).

set nh1.adulthistory;

Use the set statement to bring in the adult history questionnaire file.

keep seqn N1AH0290 N1AH0423 N1AH0284 N1AH0287 N1AH0288 N1AH0293

N1AH0294 N1AH0472;

Use the keep statement to select the variables of interest.

data anthro;

Use the data step to create the dataset for your anthropometric measurement data (anthro).

set nh1.anthro;

Use the set statement to bring in the anthropometric file.

keep seqn N1BM0260 N1BM0266 N1BM0101 N1BM0104 N1BM0103 N1BM0112 N1BM0158 N1BM0164 N1BM0170 N1BM0176 N1BM0182 N1BM0188 N1BM0194 N1BM0196;

Use the keep statement to select the variables of interest. Note that we have included all the demographic variables and weights from this file.

data genmedical;

Use the data step to create a dataset for your general medical history supplement data (GenMedical).

set nh1.genmedical;

Use the set statement to bring in the general medical history supplement file.

keep seqn N1GM0378 N1GM0379;

Use the keep statement to select the variables of interest. Note that this data set was collected on the detailed subsample and has substantially fewer observations than the others.

 

 

Step 2 Check results

After keeping the variables, it is a good idea to check the contents again to make sure that the datasets were kept with the correct variables in them and with the total number of variables expected.

Highlighted results of the proc contents procedure on the new datasets are:

 

 

close window icon Close Window