Date: Sun, 21 Dec 2008 13:27:25 -0800
Reply-To: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject: Re: Re-formatting date fields
In-Reply-To: <200812212104.mBLBlDNW006993@malibu.cc.uga.edu>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
There are two separate issues here: how the data are stored, and how
the data are displayed.
It appears that you have a variable containing a SAS datetime value.
You can create new variables using the DATEPART and TIMEPART functions
(<http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000245852.htm
>). You should then assign a date format to the variable you created
with the datepart function, and a time format to the variable you
created with the TIMEPART function.
Or you can keep the datetime value, and display it with a format that
shows only the date portion using the DTDATE format. There doesn't
appear to be a format that will show only the time portion, but
perhaps someone can correct me on this.
=====
18 data _null_;
19 test = '21dec2008:12:35:56'dt;
20 dpart = datepart(test);
21 put dpart=date9.;
22 tpart = timepart(test);
23 put tpart=time8.;
24 put 'Dtdate format ' test=dtdate9.;
25 run;
dpart=21DEC2008
tpart=12:35:56
Dtdate format test=21DEC2008
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
=====
--
Jack Hamilton
jfh@alumni.stanford.org
Videtis illam spirare libertatis auram
On Dec 21, 2008, at 1:04 pm, Ryan Utz wrote:
> I'm importing a date and time field from Access. It arrives in SAS
> with the
> full date/time information:
>
> 01JUN2001:00:20:00
>
> Once in, however, I'd like to re-format it so it shows just the date
> (in the
> form 6/1/2001) or just the time (00:20:00). I don't care if I lose
> information, as this is part of a procedure to create a bunch
> of .csv files.
> Is it too much to ask to display less information?!?
>
> Thanks,
> r