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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.