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,
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.