I'm using the online SAS Studio I'm trying to create a new variable while doing a then do loop but it doesn't seem to work, any suggestions?
This is my code....
Data golf;
infile '/home/c153469110/golf.txt';
input Distance_yards 18-22
Golfer_ID 28-29
Brand $ 39;
run;
proc print data=golf;
run;
Data golf;
set golf;
if Distance_Yards<290 then Distance_Catagory='Poor';
else if Distance_Yards >=290 then Distance_Catagory='Average';
else if Distance_Yards >310 then Distance Catagory='Above Average';
run;
Your third option will never be reached. Expand your second condition:
else if Distance_Yards >=290 and Distance_Yards <= 310 then Distance_Catagory='Average';
Your third option will never be reached. Expand your second condition:
else if Distance_Yards >=290 and Distance_Yards <= 310 then Distance_Catagory='Average';
It seems you have an invalid variable name, change the last assignment:
then Distance_Catagory='Above Average';
Note the underline that replaces the blank.
If that was not the reason, be more specific what "does not work" and post the log. Use the {i} button for that.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.