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 (November 1999, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 6 Nov 1999 19:29:49 -0800
Reply-To:   vwilkins@MY-DEJA.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   vwilkins@MY-DEJA.COM
Organization:   My Deja Email (http://www.my-deja.com:80)
Subject:   Re: A Time check poll
Comments:   To: "Berryhill, Tim" <TWB2@pge.com>
Content-Type:   text/plain; charset=us-ascii

This doesn't work if it allows times greater than 24:00.

I was just trying to see if there was a simple way to do a validation of a character value to see if it is a valid clock time. I wanted a one line quick easy solution. It seems that what I am doing is about as simple as it gets.

Thanks for all who have attempted to solve this one.

Vicki

--

On Fri, 5 Nov 1999 18:16:50 Berryhill, Tim wrote: >OK. The input is 4 characters which you plan to interpret as a two digit >hour value and a two digit minute value. May I assume hours and minutes >less than 10 will be padded with zeros? Define an informat: > >DATA CNTLIN; > RETAIN FMTNAME "TIMTIME" START "????" TYPE "I"; > DO HOUR=0 TO 23; > SUBSTR(START,1,2)=PUT(HOUR,Z2.); > DO MINUTE=0 TO 59; > SUBSTR(START,3,2)=PUT(MINUTE,Z2.); > LABEL=HOUR*60*60 + MINUTE*60; > OUTPUT; > END; > END; > START="2400"; > LABEL='24:00'T; > OUTPUT; > HLO='O'; > LABEL=''; > OUTPUT; >RUN; > >PROC FORMAT CNTLIN=CNTLIN; >RUN; > >DATA TEST; > INPUT TIME TIMTIME.; > PUT TIME=; >CARDS; >1112 >0113 >2634 >RUN; > >> ---------- >> From: California Doll[SMTP:vwilkins@MY-DEJA.COM] >> Reply To: California Doll >> Sent: Friday, November 05, 1999 5:19 PM >> To: SAS-L@LISTSERV.UGA.EDU >> Subject: Re: A Time check poll >> >> It doesn't stop at 2400..... >> >> 1 data; >> 2 time24 = hms(25,0,0); >> 3 format time24 hhmm5.; >> 4 put time24=; >> 5 run; >> >> TIME24=25:00 >> NOTE: The data set WORK.DATA1 has 1 observations and 1 variables. >> NOTE: The DATA statement used 1.76 seconds. >> >> I have not seen a SAS function or informat that will error, give a note >> or a null value on an incorrect clock time with out a lot of extra >> coding. I would like a SIMPLE one line assignment that if the time >> values is missing then this means that the values is either missing or >> an incorrect time value. It works with dates such as: >> 19 data; >> 20 format tdate mmddyy10.; >> 21 date='12/12/1999'; >> 22 tdate=input(date, ?? mmddyy10.); >> 23 put tdate=; >> 24 date='25/12/1999'; >> 25 tdate=input(date, ?? mmddyy10.); >> 26 put tdate=; >> 27 run; >> >> TDATE=12/12/1999 >> TDATE=. >> NOTE: The data set WORK.DATA4 has 1 observations and 2 variables. >> NOTE: The DATA statement used 1.1 seconds. >> >> I guess this will change nothing in the work I am doing.... >> >> -- >> California Doll >> It takes time to be a success, >> but time is all it takes. >> - Anonymous >> >> In article <000D5431.C21292@westat.com>, >> ABELSOR <ABELSOR@WESTAT.COM> wrote: >> > Well, I stand corrected. However, the SAS function HMS does not >> (according to >> > TFM) accept an hour greater than 23. A test contradicts this, though. >> > >> > 1 data; >> > 2 time24 = hms(24,0,0); >> > 3 format time24 hhmm5.; >> > 4 put time24=; >> > 5 run; >> > >> > TIME24=24:00 >> > NOTE: The data set WORK.DATA1 has 1 observations and 1 variables. >> > NOTE: The DATA statement used 0.28 seconds. >> > >> > So, I conclude that any solution to this problem will have to take >> 2400 as a >> > valid value. >> > >> > Bob Abelson >> > Westat >> > >> > ____________________Reply Separator____________________ >> > Subject: Re: A Time check poll >> > Author: "CUMMING; GORDON (PB)" <GC6872@MSG.PACBELL.COM> >> > Date: 11/04/1999 1:43 PM >> > >> > I was brought up under the belief that time went as follows >> > 23:59:59.99, 24:00:00.00, 00:00:00.01 and with rounding 23:59, >> > 24:00, 00:00 depending on the resolution of your clock. Most >> > clock displays ignore the 24:00 as it comes by so fast and why >> > add extra work for a perfect clock. If you need it why not use >> > an analog timepiece. So for all purposes 23:59 < 24:00 < 00:00 >> > in other words 24:00 does not equal 00:00 mathematically. >> > >> > _gordon >> > >> > > After talking with many of the people I work with about this, I >> thought >> > > I would come to the newgroup with many different views. Given a >> > > character variable (mytime) that is 4 chars long containing time >> values >> > > (hhmm) how would you check for valid clock time (24 hour clock). >> One >> > > obvious answer is to strip out the hours and minutes and check each >> for >> > > valid values (if 0 > hour > 24 or if 0 > mins > 59 then ERROR >> CONDITION) >> > > but I would like to take a pole on the different methods used. Some >> > > here have used methods that allow an hour of 25...and I never had an >> > > hour of 25 on my clock. Remember this is clock time not elapsed >> time. >> > > >> > > Regards, >> > > Vicki aka California Doll >> > > The great doing of little things makes the great life. >> > > - Eugenia Price >> > >> >> >> Sent via Deja.com http://www.deja.com/ >> Before you buy. >> >

--== Sent via Deja.com http://www.deja.com/ ==-- Share what you know. Learn what you don't.


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