Hi, I'm pretty new SAS. I have a piece of SAS code (pasted below) which has to be re-written in SQL. Text in bold represents the columns from the Dataset .Please let me know if you need more details. data egs_work_suspends_2; set egs_work_suspends_1; by work_id; format saveprevstatus $100.; retain saveprevstatus; format savetmstp datetime26.6; retain savetmstp; prevstatus = saveprevstatus; format suspendtmstp datetime26.6; suspendtmstp = savetmstp; format suspendtime 8.; if work_status = 'Suspended' then do; saveprevstatus = work_status; savetmstp = work_status_tmstp; end; if prevstatus = 'Suspended' and work_status = 'Resumed' then do; paired = 1; suspendtime = work_status_tmstp - suspendtmstp; saveprevstatus = .; savetmstp = .; end;
... View more