Hi,
I am trying to create a new variable from information already in my data set. I used an if then statement to do so, however the code is reading but it will not make it a new variable in my data set. When I try to use a Acecutoff variable later in my code, it tells me it is not found. When I do proc print then it variable has a a triangle looking shape with an A inside of it, not a circle with a number let the rest. It would be greatly appreciated if someone could tell me where I am going wrong.
data aces2;
set b.aces;
if ACE_SCORE >=4.0 then
Acecutoff="4 or greater";
else if ACE_SCORE <3.0 then
Acecutoff="less than 4";
run;
proc print;
run;
Your code looks fine (other than not handling all possible values). Are you sure you are looking at the right dataset? Did you check your log for errors?
data aces ;
id+1;
input ace_score ;
cards;
1
2
3
4
5
;
data aces2;
set aces;
if ACE_SCORE >=4.0 then Acecutoff="4 or greater";
else if ACE_SCORE <3.0 then Acecutoff="less than 4";
run;
proc print;
run;
ace_ Obs id score Acecutoff 1 1 1 less than 4 2 2 2 less than 4 3 3 3 4 4 4 4 or greater 5 5 5 4 or greater
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.