Hi all, I am trying to calculate number of hours from surgery time out and time stamp when heart rate is recorded. I have time stamp for heart rate in all the rows but not for the surgery time out. I know how to calculate number of hours from two time stamps but since time out is not recorded for each row, I am not able to do it. I have tried lag fuction but no help. Can some one please help me. Attached is the fabricated data. I want to calculate the difference in hours from time_out to time heart rate recorded for each row. Thanks data hr; infile datalines missover; input encounter date mmddyy10. hr_ts : datetime. hr time_in : datetime. time_out : datetime.; format date mmddyy10. hr_ts datetime. time_in datetime. time_out datetime.; datalines; 5307 4/18/2014 18APR14:14:28:00 85 18APR14:07:12:00 18APR14:13:15:00 5307 4/18/2014 18APR14:17:00:00 124 18APR14:07:12:00 18APR14:13:15:00 5307 4/19/2014 19APR14:01:13:00 125 5307 4/19/2014 19APR14:04:00:00 130 5307 4/20/2014 20APR14:13:05:00 99 1602 1/06/2012 06JAN12:14:00:00 89 06JAN12:07:20:00 06JAN12:13:09:00 1602 1/06/2012 06JAN12:15:00:00 109 06JAN12:07:20:00 06JAN12:13:09:00 1602 1/07/2012 07JAN12:23:00:00 99 1602 1/07/2012 07JAN12:01:00:00 90 1602 1/07/2012 07JAN12:23:00:00 99 1602 1/07/2012 07JAN12:02:00:00 89 ; run; proc print data=work.hr; run;
... View more