Date: Tue, 9 Dec 2008 12:58:29 -0800
Reply-To: Adriano Rodrigues <adriano@GPP.COM.BR>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Adriano Rodrigues <adriano@GPP.COM.BR>
Subject: RES: why this funcition timepart not work?
In-Reply-To: <482249F865060740AE33815802042D2F02C46D99@LTA3VS012.ees.hhs.gov>
Content-Type: text/plain; charset="iso-8859-1"
So IF i have this character variable (format 08/14/08 16:12:30 BRT) i
really must use substr?
Thanks,
Adriano
-----Mensagem original-----
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] Em nome de Fehd,
Ronald J. (CDC/CCHIS/NCPHI)
Enviada em: terça-feira, 9 de dezembro de 2008 06:52
Para: SAS-L@LISTSERV.UGA.EDU
Assunto: Re: why this funcition timepart not work?
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
>
>
|