I have the current sas code that works fine:
DATA td.data_new set td.data; if not missing(A) then Points = 250; else if B >= 10 and C= 0 then Points = 230; else if D <6 and E >60 then Points = 150; run;
I want to convert this to some equivalent SQL code, so that I can use it in a proc sql statement. Any help would be appreciated, thanks.
You need to mention "ELSE" only once at the end and remove commas.
proc sql;
create table data_new as
select a,b,c,d,e,
case when a ne . then 250
when b>=10 and c=0 then 230
when d<6 and e>60 then 150
else . end as points
from data;
quit;
Best,
please try
proc sql;
create table td.data_new as select a,b,c,d,e, case when a ne . then 250 else when b>=10 and c=0 then 230, else when d<6 and e>60 then 150 else . end as points from td.data;
quit;
Thank you but I am receiving this error?
You need to mention "ELSE" only once at the end and remove commas.
proc sql;
create table data_new as
select a,b,c,d,e,
case when a ne . then 250
when b>=10 and c=0 then 230
when d<6 and e>60 then 150
else . end as points
from data;
quit;
Best,
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.