Date: Wed, 13 Mar 1996 15:27:50 -0500
Reply-To: AdamHndrx <adamhndrx@aol.com>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: AdamHndrx <adamhndrx@AOL.COM>
Organization: America Online, Inc. (1-800-827-6364)
Subject: Re: Time Conversion
SAS already supplies a whole set of functions for handling time values.
Here's a log of a sample program using uses some of the SAS time
functions:
1 proc sql;
2 create table time
3 (time num format=time., am_pm num);
NOTE: Table WORK.TIME created, with 0 rows and 2 columns.
4 insert into time
5 values('11:05:34't, 1)
6 values('11:50:04't, 2);
NOTE: 2 rows were inserted into WORK.TIME.
7
^L3 The SAS System
12:23 Tuesday, March 12, 1996
NOTE: PROCEDURE SQL used:
real time 0.20 seconds
cpu time 0.09 seconds
8 data time(keep=time am_pm);
9 set time;
10 put 'Before: ' _n_= time=;
11 hr = hour(time);
12 if am_pm = 2
13 then time = hms(hr+12,minute(time),second(time));
14 put 'After: ' _n_= time=;
15 run;
Before: _N_=1 TIME=11:05:34
After: _N_=1 TIME=11:05:34
Before: _N_=2 TIME=11:50:04
After: _N_=2 TIME=23:50:04
NOTE: The data set WORK.TIME has 2 observations and 2 variables.
NOTE: DATA statement used:
real time 0.29 seconds
cpu time 0.11 seconds
NOTE: The SAS System used:
real time 1.34 seconds
cpu time 0.71 seconds
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
Adam Hendricks
ICOS Corporation
Bothell, Wa