LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 29 Dec 2008 23:58:42 -0500
Reply-To:     Don Henderson <donaldjhenderson@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:     RFC822 error: <W> MESSAGE-ID field duplicated. Last occurrence
              was retained.
From:         Don Henderson <donaldjhenderson@HOTMAIL.COM>
Subject:      Re: Time format with leading zero?
Comments: To: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
In-Reply-To:  <40567CBD-7C8C-4FBA-A1CA-601485D889A7@alumni.stanford.org>
Content-Type: text/plain; charset="us-ascii"

But one must be careful about the width used for the time format as demonstrated by:

1 data _null_; 2 dt = datetime(); 3 days = date(); 4 hours = days*24; 5 t = time(); 6 put days=best8. hours=best8. dt=time18. dt=time. t=time18.; 7 run;

days=17895 hours=429480 dt=429503:54:33 dt=429503 t=23:54:33

Note how the dt value displayed using the time18. format shows an hours value of 429503 which is the number of days * 24 + 23. But if one uses the default width for the time format is shows only the "most significant digits" which in this case it determines to be the number of hours. I doubt that many folks would see a datetime or time value displayed that way and realize it was the number of hours.

Regards, donh

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of Jack Hamilton > Sent: Monday, December 29, 2008 11:32 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Time format with leading zero? > > On Dec 29, 2008, at 8:02 pm, Howard Schreier wrote: > > > Interesting. Why the "current" day? It could be any day, > possibly one > > not indicated. > > Correct. I suspect it was easier to write that way. Perhaps > the editors felt that a simple "value representing the number > of seconds since midnight", without mentioning days, lacked a > certain je ne sais quoi. > > > It could be not specific to a particular day (eg, answer to the > > question "what time do you usually awaken?"). Why the limit > of 86,400? > > A time value may report a duration rather than a time of day (eg, > > answer to the question "how long will it take you to get from your > > home to the SAS Global Forum?"). > > It's probably worth mentioning somewhere that TOD. prints a > time modulo 24 hours, and time. prints the complete time. > > ===== > 1 data _null_; > 2 t = 200000; > 3 put t=tod5. t=time.; > 4 run; > > t=07:33 t=55:33:20 > ===== > > > -- > Jack Hamilton > jfh@alumni.stanford.org > Videtis illam spirare libertatis auram > > > > > > On Dec 29, 2008, at 8:02 pm, Howard Schreier wrote: > > > On Mon, 29 Dec 2008 19:21:43 -0800, Jack Hamilton > > <jfh@STANFORDALUMNI.ORG > > > > > wrote: > > > >> <http://support.sas.com/onlinedoc/913/docMainpage.jsp> says: > >> > >> SAS time value > >> > >> is a value representing the number of seconds since midnight > >> of the current day. SAS time values are between 0 and 86400. > > > > Interesting. Why the "current" day? It could be any day, > possibly one > > not indicated. It could be not specific to a particular day (eg, > > answer to the question "what time do you usually awaken?"). Why the > > limit of 86,400? A time value may report a duration rather > than a time > > of day (eg, answer to the question "how long will it take > you to get > > from your home to the SAS Global Forum?"). > > > >> > >> SAS datetime value > >> > >> is a value representing the number of seconds between > >> January 1, 1960 and an hour/minute/second within a specified > >> date. > >> > >> So datetime values for January 1, 1960 will be in the same > range as > >> time values for 00:00:00 to 24:00:00. As long as your > values are in > >> that range, you'll be OK. > >> > >> If you have a value greater than 24 hours, though, and you want to > >> display it in hours:minutes:seconds (or hours:minutes), > you're out of > >> luck with TOD: > >> > >> ===== > >> 1 data _null_; > >> 2 t = '23:59:59't; > >> 3 t2 = t + 100; > >> 4 put t=tod5. t2=tod5.; > >> 5 run; > >> > >> t=23:59 t2=00:01 > >> ====== > >> > >> > >> > >> -- > >> Jack Hamilton > >> jfh@alumni.stanford.org > >> Videtis illam spirare libertatis auram > >> > >> > >> > >> > >> > >> On Dec 29, 2008, at 5:06 pm, John Whittington wrote: > >> > >>> At 19:26 29/12/2008 -0500, Ian Whitlock wrote: > >>>> John, > >>>> > >>>> You wanted a time format with leading 0's. > >>>> > >>>> The TOD format has been suggested, but it works with DATETIME > >>>> values not TIME values. If your variable is time then > you may have > >>>> to roll your own format. > >>> > >>> Ian, that's what I thought, but when two people suggested TOD, I > >>> thought I ought to try it - and it appears to work fine > (with TIME, > >>> as well as DATETIME, values): > >>> > >>> 21036 data _null_ ; > >>> 21037 mytime = '07:59't ; > >>> 21038 put "mytime = " mytime tod5. ; > >>> 21039 run ; > >>> > >>> mytime = 07:59 > >>> > >>> I wonder if there are some risks in doing this (i.e. > situations in > >>> which it doesn't work as desired)? > >>> > >>>> PS: It has been a long time. Glad your back. > >>> > >>> Thanks. It's good to be in contract with you again, too. I've > >>> never actually been 'away', in terms of reading SAS-L, > but life has > >>> been so hectic for longer than I care to remember that I've had > >>> little time to actually contribute. My occasional > appearances these > >>> days tend to be when I need help, rather than am offering > it - which > >>> is a bit parasitic, but I live in hope of the fact that > there will > >>> soon be more than 24 hours in a day, such that I'll be > able to be a > >>> bit more conspicuous and contributive again! > >>> > >>> Kind Regards, > >>> > >>> > >>> John > >>> > >>> ---------------------------------------------------------------- > >>> Dr John Whittington, Voice: +44 (0) 1296 730225 > >>> Mediscience Services Fax: +44 (0) 1296 738893 > >>> Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk > >>> Buckingham MK18 4EL, UK > >>> ---------------------------------------------------------------- >


Back to: Top of message | Previous page | Main SAS-L page