Date: Fri, 15 Dec 2006 22:18:14 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: How to calculate time difference
On Fri, 15 Dec 2006 08:38:35 -0800, Suthakar Iyer <suthakariyer@YAHOO.COM>
> Time1 is a Character variable with the format 29:22:41
> Time2 is a Numeric variable with the format 32.55
> If the time1 is different from time2 by more than 0.5 hrs , I need to
flag them or identitfy them.
> Thanks for the help in advance.
Here's a solution that is fully abstract in that it does not require
knowledge of how SAS represents times internally.
time1 = '29:22:41';
time2 = 32.55;
flag = abs(input(time1,time8.) - hms(time2,0,0) ) > hms(0.5,0,0);
There are advantages to using SAS date and time variables throughout. In
this case the assignment statement would simplify to
flag = abs(time1 - time2) > hms(0.5,0,0);