|
SAS treats dates, datetimes, and times
as numeric scalars.
if your variable dt were a number
then your example would work.
Ron Fehd the scalar maven CDC Atlanta GA USA RJF2 at cdc dot gov
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
> [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Adriano Rodrigues
> Sent: Tuesday, December 09, 2008 2:52 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: why this funcition timepart not work?
>
> Hi,
>
>
>
> Just studying some functions I never use, why this don't
> work? Is because
> SAS don't understand my variable dt as date?
>
>
>
>
>
> data parthour;
>
> input dt $ 50.;
>
> hour=substr(dt,10,8);
>
> hour2=timepart(dt); /* function timepart test*/
>
> cards;
>
> 08/14/08 16:12:30 BRT
>
> 08/14/08 16:12:30 BRT
>
> 08/14/08 16:12:30 BRT
>
> 08/14/08 16:12:30 BRT
>
> 08/14/08 16:12:30 BRT
>
> 08/14/08 16:12:40 BRT
>
> 08/14/08 16:12:50 BRT
>
> 08/14/08 16:12:50 BRT
>
> 08/14/08 16:12:50 BRT
>
> ;
>
> run;
>
> proc print;
>
> run;
>
>
>
>
>
> Obs dt hour hour2
>
>
>
> 1 08/14/08 16:12:30 BRT 16:12:30 .
>
> 2 08/14/08 16:12:30 BRT 16:12:30 .
>
> 3 08/14/08 16:12:30 BRT 16:12:30 .
>
> 4 08/14/08 16:12:30 BRT 16:12:30 .
>
> 5 08/14/08 16:12:30 BRT 16:12:30 .
>
> 6 08/14/08 16:12:40 BRT 16:12:40 .
>
> 7 08/14/08 16:12:50 BRT 16:12:50 .
>
> 8 08/14/08 16:12:50 BRT 16:12:50 .
>
> 9 08/14/08 16:12:50 BRT 16:12:50 .
>
>
>
> Thanks in advance,
>
> Adriano
>
>
|