BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
saza
Quartz | Level 8

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
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";

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
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";

 

--
Paige Miller
saza
Quartz | Level 8
Thank you so much! I did the same for 60-69 and that worked!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 647 views
  • 0 likes
  • 2 in conversation