Hi,
I have the following code:
Data test;
Dt=201210131;
Run;
Data test1;
Set test;
Dt1=put(dt,yymmdd10.);
Run;
When I run the second data step I am getting an error message:
"Date out of range"
Please share your thoughts on how to fix this error.
Thanks.
Correct the data! 2012 10 131?
Oops..that was a typo,the date is 20120131.
Then try:
Data test;
Dt=20120131;
Run;
Data test1;
Set test;
Dt1=input(put(dt,8.),yymmdd10.);
Run;
SAS treats dates as integer numbers with Day 0 being 1 January 1960, so when you assign the number 201210131, what are you intending the number to mean?
The reason SAS gives the error is because the number that is assigned to variable DT is interpreted as the 201210131st day after 1 January 1960, which is more than half a million years in the future! I am guessing this is probably not what you meant. But what did you mean? Is this number 31 January 20121 - unlikely but possible - or 13 October 2012 - maybe - or did you intend to type 31 January 2012 but made a typo and inserted an extra digit in the middle of the number.
To "fix this error" I would suggest you start by reading about SAS Date, Time, and Datetime Values in the documentation to first understand what the error is you are trying to fix. There you will find that SAS can only display Gregorian calendar dates between 1582 and 19900. Also dates prior to September 1752 in British jurisdictions can be dual dated, while dates in other jurisdictions depend on when the calendar was adopted (Greece adopted the Gregorian calendar in 1923, for example.) Once you understand how SAS represents dates, then search for various papers that explain how to deal with representing dates in SAS and the error you have encountered. There are plenty of solutions documented.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.