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

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Your third option will never be reached. Expand your second condition:

else if Distance_Yards >=290  and Distance_Yards <= 310 then Distance_Catagory='Average';

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Your third option will never be reached. Expand your second condition:

else if Distance_Yards >=290  and Distance_Yards <= 310 then Distance_Catagory='Average';
KatieMessi
Calcite | Level 5
It’s not working for me
Kurt_Bremser
Super User

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.

SAS Innovate 2025: Register Today!

 

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.


Register now!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1072 views
  • 0 likes
  • 2 in conversation