I did the following code and got expected result (I only add a blank in input data separating date and time part):
[pre]
data i;
input s anydtdtm19. e anydtdtm19.;
format s e datetime20. dur time8.;
dur=e-s;
datalines;
12/11/2010 10:20:30 12/11/2010 13:20:40
29/12/2010 10:30:30 30/12/2010 15:20:40
14/10/2010 08:40:20 14/10/2010 17:30:49
;
run;
Dataset i:
s e dur
11DEC2010:10:20:30 11DEC2010:13:20:04 2:59:34
29DEC2010:10:30:30 30DEC2010:15:20:04 28:49:34
14OCT2010:08:40:20 14OCT2010:17:30:04 8:49:44
[/pre]
Sincerely,
SPR
What exactly is not working? When you apply Peter's solution, what error are you getting? Are your two datetime variables correctly holding SAS datetime values?
Hi:
Have you tried using the TIME format with your calculated duration???
Are you certain that all your durations are going to "fit" in TIME10?? What if your duration is more than 9999 hours??? More than 2 years (which is approx 17,000 hours)??