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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.