Sie sind auf Seite 1von 2

PH6420 Fall 2015 : Assignment 3

Due: October 26, 2015

Write one program for parts A/B and one program for part C. When creating new variables make
sure that you account for possible missing data in the original variable.
Submit the 2 SAS programs answering all questions. You may include the output if it helps you
answer the questions, but it is not required.

Create a SAS dataset that reads in the variables age, sex, income, educ, hdlbl, potassbl,
and potass12 from tomhs.dat.


Within the data step create a new variable called agecat that divides age into 5 categories:
45-49; 50-54; 55-59; 60-64; 65-69. Gives values of 1-5 for the categories.


Create a new variable called income40 equal to 0 if income is less than $40,000 and
equal to 1 if income is $40,000 or more. Create a new variable called collgrad equal to 0
if the participant did not graduate from college and equal to 1 if the participant graduated
from college. (see study forms for income and education categories).


Create a new variable that is the smallest of the two serum potassium values (variables
potassbl and potass12).


Run PROC MEANS for all variables to help verify that you read-in and created the new
variables correctly (For example, income and income40 should have the same number of
valid observations). What percentage of participants graduated from college? What
percentage of participants have incomes of 40K or more.


Using PROC FREQ display the 2 by 2 table of income40 and collgrad. Are college
graduates more likely than non-graduates to make $40,000 or above? Give summary
statistics to justify your answer (You may add the CHISQ option to the table statement if
you want to statistically test if the two variables are related).


Display the frequency distribution of the smallest potassium. What percentage of

participants had a serum potassium less than 3.5.


Most studies show that women have lower rates of heart disease then men. One
mechanism for this lower rate is that women have higher HDL cholesterol than men. Run
a SAS procedure that addresses this question using the TOMHS data. Do women tend to
have higher HDL than men?



Add to your program in Part A syntax to create suitable formats (use PROC FORMAT)
for sex, income and agecat. (this can be put at the top of your program or after the data


Add suitable labels for each variable read in and each new variable. This can be put in the
data step.


Use PROC FREQ to obtain a frequency distribution of sex, income and agecat. Apply
the formats created so that the formatted values are displayed rather than the numeric
values. What percentage of subjects are 65 years or older?

The following observations are made-up data from four hospital stays. The data is comma
delimited with the variables: Patient ID, date of birth of patient, date of hospital admission, date
of hospital discharge, and total cost of stay in dollars.

Create a SAS dataset that reads in the data. Call the variables id, dob, admit, dischrg,
and fee. Read in id as a character variable. You may type the data within the program or
read it in from the data file hosp.csv on the class website. Note: To input the date
variables you will need to use colon modifiers on the input statement (See Lecture 2).


Compute a variable called staydays which is the number of days spent in the hospital..


Create a variable called age that is the age of the patient in years at time of admission.


Create a variable called costperday that is the average cost per day.


Use PROC PRINT to display all the variables. Provide date formats for each date