For the below project3 I have tried to fix the errors and write code by my understanding but after running my code for question 5 I got the exact answer mentioned but for question no. 6 I m getting value as 1557 instead of 1405 which is the correct answer. So can anyone please see my coding and let me know where I am lacking. that would be really helpful. Thanks in advance.
* Here is my code :
data work.lowchol work.highchol work.misschol;
set sashelp.heart;
if cholesterol lt 200 then
do;
lowchol="low";
output lowchol;
end;
else if cholesterol ge 200 then
do;
highchol="high";
output highchol;
end;
else if cholesterol=. then
do;
misschol="miss";
output misschol;
end;
run;
MISSING value is always LESS THAN any given value. So part of the program logic that needs adjustment is order of comparison. If you look in LOWCHOL data set you should find all of the missing cholesterol values as well as the non-missing less than 200.
Hint: SHOW your log, copy the log text with code and all the notes. Copy the text, on the forum open a text box using the </> icon that appears above the message window and paste the text. The text box will preserve the formatting of any diagnostic messages that SAS often provides while the main message windows on this forum will reformat pasted text.
Then ask about the problem with what your result was. Like, why does my Lowchol data set have more than 1405 observations?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.