@bbortey wrote:
Hi guys,
I have converted a character variable to sas date for calculation.
After conversion I realized some future dates for instance '2Oct2027' is being converted to '2Oct 1927' instead. Please how do I correct such an error to reflect the correct sas date of '2Oct2027'.
thank you.
What you say is quite likely related to the use of two-digit years some where. Depending on the value of your option YEARCUTOFF a two-digit year is assumed to be in 1900's if the value is less.
Run this code snippet:
proc options option=yearcutoff;run;
and see if the log shows something like:
YEARCUTOFF=1926 Specifies the first year of a 100-year span that is used by date informats and
functions to read a two-digit year.
or any value smaller than 1927.
The solution, depending on your range of dates may be to set the YEARCUTOFF later than your problem year.
OR provide examples of the actual original character values and the code you used to do the conversion.
For instance when I run this code:
data example;
x='02OCT27';
/* my yearcutoff is 1926 which I believe is the current default for SAS 9.4*/
y=input(x,date7.);
format y date9.;
run;
The Y value is 02OCT1927.
... View more