|
hi ... from version 9.3 ...
if it's already a character variable, just reread the value with a time-related informat ...
data x;
input tm : $4. @@;
datalines;
317 317 336 336 336 1550 1550 1550 1544 1544 1547 1547 1547
;
run;
data y;
set x;
tod = input(tm,hhmmss.);
format tod time5.;
run;
if not version 9.3 (assumes the length of the character variable with the time of day is 4)...
data y;
set x;
tod = input(catx(':',substr(right(tm),1,2),substr(right(tm),3)),time5.);
format tod time5.;
run;
Mike Zdeb
U@Albany School of Public Health
One University Place (Room 119)
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
________________________________________
From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Dan Abner [dan.abner99@GMAIL.COM]
Sent: Friday, November 25, 2011 9:49 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Converting unformatted character variable values to SAS time values XXXX
Hello everyone,
I have a character variable of unformatted 24 hour times (see below). What
is the easiest way to convert these to a proper numeric SAS time variable?
317
317
336
336
336
1550
1550
1550
1544
1544
1547
1547
1547
Thanks!
Dan
|