I cannot figure out why my SAS programming codes don't run through!! Urgent!! Please help!!
Here are my codes:
LIBNAME t "C:\0. Zxx_BEST\SAS_folder";
DATA tomhs;
set t. tomhscv(KEEP= group age sex eversmk nowsmk sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12 cvd);
if (eversmk = 1 and nowsmk = 1) then smoke = 1;
else smoke = 0;
if glucosbl > 126 then dm = 1;
else dm=0;
if group < 6 then active = 1;
else active=0;
if group = 1 or group = 0 then rxold =1;
else
if group = 2 or group = 4 or group = 5 then rxold =2;
run;
proc freq data = tohms;
tables smoke /nocum;
run;
proc freq data = tohms;
tables cvd /nocum;
run;
proc freq data = tohms;
tables cvd * active;
run;
Proc Logistic Data = tohms;
Model cvd = age sex sbpbl cholbl smoke dm;
run;
proc ttest data=tohms;
Paired cholbl * chol12;
run;
Here are the instructions:
A SAS dataset called tomhscv on the class website contains risk factor and cardiovascular outcome data on all 902 participants in the TOMHS study. The following variables are on the dataset.
Variable name:
Description
group treatment group assigned (1-5 active drug, 6=placebo) age age of participant at entry (baseline)
sex gender, 1=men, 2=women
eversmk question of whether the participant ever smoke cigarettes (1=yes, 2=no)
nowsmk question of whether the participant now smokes cigarettes (1=yes, 2=no). This question is asked only if the the variable eversmk = 1. These questions were asked at baseline.
sbpbl systolic BP at baseline
sbp12 systolic BP at 12-months
cholbl blood serum cholesterol at baseline
chol12 blood serum cholesterol at 12-months
hdlbl blood HDL cholesterol at baseline
hdl12 blood HDL cholesterol at 12-months
glucosbl blood glucose at baseline
glucos12 blood glucose at 12-months
cvd CVD event status during the study (1=yes,2=no) Do the following:
1. In a data-step read in the dataset tomhscv creating a work dataset called tomhs and adding the following variables.
(a) Define a variable called smoke = 1 if the participant is a current smoker at baseline and 0 if not a current smoker at baseline, i.e. an ex-smoker or never-smoker (use variables eversmk and nowsmk).
(b) Define a variable called dm = 1 if the participant's glucose at baseline is above 126 mg/dl and 0 if 126 mg/dl or below at baseline.
(c) Define a variable called active = 1 if on active BP medication and 0 for placebo.
(d) Define a variable called rxold = 1 if group is equal to 1 or 3, and = 2 if group is equal to 2,4, or 5. The placebo group (group = 6) should be missing.
When creating new variables be sure to account for missing data. For example, the variable smoke should only be defined for those that completed the item eversmk.
Write SAS code to perform the following analysis and to answer the following questions. You may need to add additional variables to your dataset.
2. How many and what percentage of participants were current smokers at baseline? How many participants had missing data for smoking?
3. How many and what percentage of participants experienced a CVD event during the study?
4. Did being on active treatment lower the risk of CVD during the trial? Give the odds ratio of CVD for active treatment versus placebo. (Hint: Use either proc freq or prog logist).
5. Using proc logist which of the following baseline variables are significantly related to CVD?
1) age, 2) gender (women versus men), 3) systolic BP, 4) serum cholesterol, 5) smoking, and
6) diabetes (variable dm). Include all these variables in one model. What is the adjusted odds ratio of CVD for smokers versus non-smokers?
6. Did the older or newer drugs reduce systolic BP more at 12-months compared to baseline? Was the difference in SBP change between the two groups significant? (Hint: Use proc ttest or proc glm).
anyone can help?
Urgent!!!
Thanks much!!
Sara Lee
The error is "ERROR: Variable CVD not found."
Search CVD in your code. Is there a typo?
According to message there is no CVD variable in your input data set.
Did you mean to create it as a new one? Then it should not appear on SET ...(keep=) statement.
What do you mean by "codes don't run through!!" ?
Do you have any error or warning in your log? if positive - post your log.
It seems that it is your homework. In any case of issue post your code, the log and describe what issues you have.
First thing to check ... is this actually part of your program:
set t. tomhscv
If so, you need to change it by removing the blank:
set t.tomhscv
If that doesn't solve things, you need to verify the spelling of the variable names in your data set:
proc contents data=t.tomhscv;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.