When I type the following code and run it, I only get "excellent" or "Not so good" as my choices, not "good" or "okay" for the intended grades.
1.Create a new dataset called ATL1 from the dataset ATLGRADES. In this data step, use IF-ELSE
statements to create a new character variable called GRADEREV with values of “Excellent” if
GRADE is between 85 and 100, “Good” if GRADE is between 70 and 84, “Okay” if GRADE is
between 60 and 69, and “Not so good” if GRADE is less than 60. Make sure you are using ELSE
statements here!;
data ATL1;
set Sarah.atlgrades;
if grade >= 85 then GRADEREV = "Excellent";
else if grade <= 70-84 then GRADEREV = "Good";
else if grade <= 60-69 then GRADEREV = "Okay";
else GRADEREV = "Not so good";
run;
else if grade <= 70-84 then GRADEREV = "Good";
SAS interprets the code 70-84 to mean 70 minus 84, which is -14. So this tests if grade <= -14 then "Good". I don't think that's what you want.
Try this:
else if 70<=grade<=84 then graderev="Good";
else if grade <= 70-84 then GRADEREV = "Good";
SAS interprets the code 70-84 to mean 70 minus 84, which is -14. So this tests if grade <= -14 then "Good". I don't think that's what you want.
Try this:
else if 70<=grade<=84 then graderev="Good";
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.