I have a dataset with about 6 million observations and this sas data step is insufficient so I was asked to run it as an sql query. I am not familiar how to phrase if then statements in sql within a select statement as well as format variables. The original code looks like this: data convert_code; format date1 date 2 mmddyy8. code $4.; set userid.code; (this table is pulled from oracle) if ID='X' then P='A'; else P='B'; If CAT in ('1','2','3') then CAT_group='ONE'; else CAT_GROUP='TWO'; if CAT_2 > '0' and CAT_2A >='1' then d=1; else d=0; date1=datepart(date1); date2=datepart(date2); if code='3' and type_code in ('A','B','C') THEN DO; if P_CODE in ('1','2','3') then P='1'; if P_CODE in ('4','5','6') then P='2'; end; if code='4' and e_code in ('A') then DO; if B_CODE in ('11','12','13') then P='3'; if B_CODE in ('14','15','16') then P='4'; end; run;
... View more