Exercises on Arrays

Using Arrays to Set up Missing Values:

1. Modify the commands shown on p. 24 of your workbook for the Owen dataset (they are included as part of the command file array.sas) so that the missing value codes for the variables HEIGHT and WEIGHT will be properly handled. Check your work by getting descriptive statistics using Proc Means.

Creating New Variables Using Arrays:

Create a new command file for this part of the exercise, and call it Exercise2.sas.

This part of the exercise uses the Tecumseh dataset in your SASDATA2 library. This dataset contains information from three rounds of data for the Tecumseh Community Health Study. The data dictionary is provided on pp. 208 and 209 in the Introduction to SAS Workshop notes.

Check to be sure that the library SASDATA2 is defined by double-clicking on your libraries icon. If it isn’t defined yet, submit a libname statement like the one below:

libname sasdata2 “e:\sasdata2”;

1. Create three new variables, LOGWT1, LOGWT2, and LOGWT3, which are equal to the natural log of weight (WTKG1, WTKG2, and WTKG3) for each round. To do this, you will need to create a new dataset using a Data Step. The commands below will get you started:

data sasdata2.tecumseh2;

set sasdata2.tecumseh;

*your commands go here;

run;

Array Challenge 1:

Again, using the Tecumseh dataset, create dummy variables for hypertension at each round of data collection: HYPERTEN1, HYPERTEN2, and HYPERTEN3. Hypertension is defined as having either SBP>140 or DBP > 90. Please include these commands in the same data step as above, so you won’t be creating another new dataset. Use Proc Freq to get the percentage of people with hypertension at each wave.

Array Challenge 2:

1. If you have time, open up the SAS command file werner2.sas. This command file is to read in the Werner Birth Control Data. Use array statements to set up the missing value codes in the dataset. To find out what the missing value codes for the variables in this dataset are, you can check the dataset description in the Introduction to SAS Workshop notes on p. 210. Get descriptive statistics for this dataset using Proc Means to check your work. Save the werner2.sas command file after you have made your changes to it.

1