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,
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: