I am using SAS University Edition. So I need to create a new column based on column x3. The new column is yes/no where 1 is yes and 0 is no. If the value of column x3 is 50 or greater, the new column would indicate 1. If it is less than 50, the new column would indicate no. I have tried various ifelse statements and I cannot seem to get it to work. I am novice to SAS, any help would be appreciated.
data work.data;
set work.import;
run; /* this premature run statement terminates the step and causes the following statements to be invalid */
/* remove it */
if x3 > 49 then X7 = 1;
else if x3 < 50 then x7 = 0;
run;
You should post your code, the log and explain what issues you have.
I am not sure how to get SAS to create the column with the data. I just keep getting errors.
data work.data;
set work.import;
run;
if x3 > 49 then X7 = 1;
else if x3 < 50 then x7 = 0;
run;
data work.data;
set work.import;
run; /* this premature run statement terminates the step and causes the following statements to be invalid */
/* remove it */
if x3 > 49 then X7 = 1;
else if x3 < 50 then x7 = 0;
run;
data work.data; set work.import; run; if x3 > 49 then X7 = 1; else if x3 < 50 then x7 = 0; run;
Remove the inner "RUN" and test the program. It can also be written as:
data work.data; set work.import; x7 = 0; if x3 > 49 then X7 = 1; run;
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.