Date: Mon, 14 Feb 2005 11:05:23 -0500
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: Date conversion
Debbie Weiss wrote:
> I have a dataset that is orginated from an AS400. It has a date field
> called Enroll_date in a numeric form of CYYMMDD. I compare it to a
> SQL table with a date field called EFFDAT which is in datetime format.
> STEP1.
> enroll=put (enroll_date, $9.); ***converst to Character
> enroll2=substr(left(enroll),2,6); ***gets rid of century
> enroll3 =input (enroll2,yymmdd6.);**sas date;
> STEP2.
> effdat2=datepart(effdat); **sas date;
> STEP3.
> if effdat2 le enroll3;
>
> Here is my problem:
> if enroll_date = 2051201 my enroll3 is equal to -20119 after the
> conversion
>
> if effdat=01DEC2004:00:00:00.000 my EFFDAT2=16406
> WHY ARE THEY NOT THE SAME? When I get to Step 3 get 0 in my resulting
> dataset. If I format the field to mmddyy8, they get format to
> 12/01/04.
Your code looks good.
-20119 is '01DEC1904'D.
Check your yearcutoff option [YCO].
options yearcutoff=1900; * generally somewhere around 1950, affects input();
data _null_;
date = -20119;
put date date9.;
datechar = '051201';
date = input (datechar,yymmdd6.); * this is where yearcutoff comes into
play;
put date date9.;
run;
----------
01DEC1904
01DEC1905
I don't know how you got that -20119 that you stated. It's one year prior
to '051201'D (when YCO between 1900 and 1905)
--
Richard A. DeVenezia
http://www.devenezia.com/