Date: Thu, 28 Sep 2000 11:19:21 -0700
Reply-To: "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Subject: Re: Converting num time in time5.
Content-Type: multipart/alternative;
Patrice-
Try the following. I've calculated the time two different ways, one
"step-by-step" and one all at once. Both give the same result.
BTW - I've yet to find a SAS informat that will deal with a time input
value that doesn't have a colon separating the hours and minutes. Like
Patrice's data, I often get files where the time is hhmmss, with no
separators. In my code below I insert the colon. One reason for posting
this is to see if someone else has a better solution!
----------------------------------------------------------------------------
---------
data temp;
input date yymmdd8. time_x;
/* Do it all one step at a time
*/
time1a = put(time_x,z6.); /* get in hhmmss format, w/ leading
0's */
time1b = substr(time1a,1,2); /* get the hours
*/
time1c = substr(time1a,3,2); /* get the minutes
*/
time1d = trim(time1b)||':'||time1c; /* put them together, separated by a
: */
time1e = input(time1d,time.); /* convert to SAS time value
*/
/* Or, put all the above together and do it at one time */
time2 =
input(substr(put(time_x,z6.),1,2)||':'||substr(put(time_x,z6.),3,2),time.);
put date= mmddyy10. time1e= timeampm. time2= timeampm.;
cards;
20000101 93526
20000103 100511
20000106 175632
run;
----------------------------------------------------------------------
Pete Lund
WA State Caseload Forecast Council
515 15th Ave SE
Olympia, WA 98504-0962
(360) 902-0086 voice
(360) 902-0084 fax
(360) 971-0962 pager
peter.lund@cfc.wa.gov
----------------------------------------------------------------------
-----Original Message-----
From: Patrice Bourdages [mailto:PBourdages@IAG.QC.CA]
Sent: Thursday, September 28, 2000 11:03 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Converting num time in time5.
Hello guys...
I've been wasting the last half hour converting a numerical time into a real
time format... Here's the situation:
I read an IBM AS/400 file using s370... informats. The time is stored in the
file in the following manner:
Date Time
20000101 93526 Which stands for Jan 01, 2000 @ 9:35
AM
20000103 100511 for 10:05 AM
20000106 175632 for 17:56 or 5:56 PM
format date yymmdd10.;
@ 1 Date s370fpd5.;
* Conversion phase (from numeric to a real date format);
Date = input( put(Date,10.0), ?? yymmdd10.);
How am I suppose to do the came thing with the "Time" field. I've tried
numerous things in this last half hour and I am now lost.
TIA
Sincerely,
Patrice :-)
[text/html]