This scenario uses the
Excel file heart.xlsx. Write a SAS program to do the following and
store the results in the data set Work.Heart.
-
Import the Excel file heart.xlsx.
-
Drop the AgeAtDeath and DeathCause
variables from the Work.Heart data set.
-
Include only the observations where
Status=Alive in the Work.Heart data set.
-
If the AgeCHDdiag variable has
a missing value (.), then do not include the value in Work.Heart.
-
Create a new variable Smoking_Status,
set its length to 17 characters, and use the following criteria:
-
If the value of Smoking is between
0 and less than 6, then Smoking_Status is "None (0–5)".
-
If the value of Smoking is between
6 and 15 inclusively, then Smoking_Status is "Moderate (6–15)".
-
If the value of Smoking is between
16 and 25 inclusively, then Smoking_Status is "Heavy (16–25)".
-
If the value of Smoking is greater
than 25, then Smoking_Status is "Very Heavy (>25)".
-
If there are any other values for
the variable Smoking, set Smoking_Status to "Error".
-
Create a two-way frequency table
using variables AgeCHDdiag and Smoking_Status and suppress column
percentage, row percentage, and cell percentage.