Hello,
Below is resultant table with just the first and last records for each application. How can I get the time difference between the first record (Start Time) and the last record (EndTime) for the same application id?
For example - AppID 1001 time difference is 0 hours, 2 minutes, 24 seconds.
Thanks!
AppID | OprID | StartTime | EndTime |
1001 | 1 | 09OCT2013:11:24:51.000000 | 09OCT2013:11:27:15.000000 |
1001 | 1 | 09OCT2013:11:26:16.000000 | 09OCT2013:11:27:15.000000 |
1002 | 2 | 09OCT2013:09:15:49.000000 | 09OCT2013:09:34:33.000000 |
1002 | 2 | 09OCT2013:09:24:16.000000 | 09OCT2013:09:34:33.000000 |
1003 | 3 | 09OCT2013:11:19:43.000000 | 09OCT2013:11:19:57.000000 |
1003 | 3 | 10OCT2013:14:50:47.000000 | 10OCT2013:14:51:16.000000 |
DATETIMEs in SAS are stored as an integer number of seconds since 1/1/1960 0:00:00. So, you can simply subtract the two values. You can then format the result with a TIME format.
Data want; set have; by appID; retain starting_time; if first.appID then starting_time=starttime; if last.appID then do; duration=endtime-starting_time; output; end; format duration TIME8.; run;
DATETIMEs in SAS are stored as an integer number of seconds since 1/1/1960 0:00:00. So, you can simply subtract the two values. You can then format the result with a TIME format.
Data want; set have; by appID; retain starting_time; if first.appID then starting_time=starttime; if last.appID then do; duration=endtime-starting_time; output; end; format duration TIME8.; run;
Thank you very much Snoopy369!
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.