Date: Wed, 15 Jul 2009 17:42:45 -0400
Reply-To: msz03@albany.edu
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Question about Date (month, year)
Content-Type: text/plain;charset=iso-8859-1
hi ... by this ...
> Thank you Mike, this is exactly what I want to do. by the way, do you
> know how to change dtdate9. to date9.?
> Melody
I assume that your dates are date-time values, not just dates
so ... here's an example ...
*
make a data set with two date-time variables
assign different formats so you can see what
the date-time really looks like
;
data test;
x = '12dec2009:12:15'dt;
y = x;
format x dtdate9. y datetime16.;
run;
*
use the DATEPART function to extract the date from the date-time
create a second variable with the same value
assign two different formats
;
data test;
set test;
a = datepart(x);
b = a;
c = a;
format a date9. b dtdate9.;
run;
*
you'll see that variable A is OK
but since variable A is JUST A DATE
showing variable B with a date-time format
shows the wrong date
variable C shows a value of 18243
since one day has 86,400 seconds,
using DTDATE (date-time) shows the SAS day 0
or 01JAN1960 since it uses SECONDS not DAYS
;
proc print data=test;
run;
OK ???
--
Mike Zdeb
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475