BookmarkSubscribeRSS Feed
renjithr
Quartz | Level 8

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.

4 REPLIES 4
art297
Opal | Level 21

Correct the data!  2012 10 131?

renjithr
Quartz | Level 8

Oops..that was a typo,the date is 20120131.

art297
Opal | Level 21

Then try:

Data test;

  Dt=20120131;

Run;

Data test1;

Set test;

  Dt1=input(put(dt,8.),yymmdd10.);

Run;

Cameron
Fluorite | Level 6

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. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 10112 views
  • 1 like
  • 3 in conversation