Date: Thu, 29 Jan 2004 12:08:52 -0800
Reply-To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject: Re: FORMAT Time Problem
Hamani this will work....
data time;
informat archive $255. ;
input archive : & $255.;
/**what you need**/
date=input(scan(archive,1,' '),mmddyy10.);
time=input(scan(archive,2,' '),time5.);
dttime=date*24*60*60+time;
format date date9. time time5. dttime datetime16.;
/**what you need**/
datalines;
11/20/2003 21:15
11/20/2003 22:15
11/20/2003 23:15
11/21/2003 00:15
11/21/2003 01:15*
11/21/2003 02:15*
11/21/2003 03:15*
;
bol
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: Elmaache, Hamani [mailto:Hamani.Elmaache@ccra-adrc.gc.ca]
Sent: Thursday, January 29, 2004 11:30 AM
To: 'Choate, Paul@DDS'; SAS-L@LISTSERV.UGA.EDU
Subject: RE: FORMAT Time Problem
Sorry Choate.
It does't work.
May be I didn't explain well my problem.
The variable archive is just one character variable that I imported from
Excel.
I have to trait it as character variable $225.
11/20/2003 21:15
11/20/2003 22:15
11/20/2003 23:15
11/21/2003 00:15
11/21/2003 01:15*
11/21/2003 02:15*
11/21/2003 03:15*
I want to extrait date and time.
Thanks a lot.
-----Original Message-----
From: Choate, Paul@DDS [mailto:pchoate@DDS.CA.GOV]
Sent: January 28, 2004 2:00 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: FORMAT Time Problem
Hamani - Try this -
data time;
input date : mmddyy10.
time TIME5.;
archive=input(put(date,date9.)||':'||put(time,time5.),datetime14.);
format date date9. time time5. archive datetime16.;
datalines;
11/20/2003 21:15
11/20/2003 22:15
11/20/2003 23:15
11/21/2003 00:15
11/21/2003 01:15*
11/21/2003 02:15*
11/21/2003 03:15*
;
The colon modifier skips the initial blank, and the time5 makes it not read
the asterisk.
Now your date is the date, time is the time, and archive is the datetime,
and your dateime functions should work.
hth
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: Elmaache, Hamani [mailto:Hamani.Elmaache@CCRA-ADRC.GC.CA]
Sent: Wednesday, January 28, 2004 9:32 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: FORMAT Time Problem
Hi sas-users.
I have hard time to get hours and minutes from the following variable (ie
Archive) that I'v gotten from excel.
Archive
11/20/2003 21:15
11/20/2003 22:15
11/20/2003 23:15
11/21/2003 00:15
11/21/2003 01:15*
11/21/2003 02:15*
11/21/2003 03:15*
I wrote the following but It does't work. I got 21:15 but as character.
data time;
attrib time format=hhmm7. informat=hhmm7.;
set waittimes;
time0=SUBSTR(Archive,12,7);
month=SUBSTR(Archive,1,2);
month_day=SUBSTR(Archive,1,5);
star=SUBSTR(time0,7,1);
if star='*' then flag=1;
else flag=0;
drop star;
time=SUBSTR(Archive,12,6);
run;
Can somebody help?
Thanks a lot.