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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 1442 views
  • 0 likes
  • 2 in conversation