BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASuserlot
Barite | Level 11

I am aware of the importance of  January 1 1960 in SAS (considers them as Birthday), SAS stores the days counting from this particular date. 

               I am not  100% sure but when sometimes I used the wrong date format / informat I used to see this date in my datasets. Can you guys please share some information on this and also provide an example where we see January 1, 1960, in the dataset because of giving the wrong format / informat?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

SAS datetime values are numbers of seconds.

SAS Date values are numbers of days.

When treat a Date value as if it should be a Datetime then the actual value is way smaller than a datetime format, or function, expects.

Data _null_;
   x=today();
   put 'Numeric value of x is ' x best5.;
   put 'X is: ' x date9. ' with date9. format';
   put 'X is: ' x datetime9. ' with datetime9. format';
run;

When you accidentally use a datetime value where a date is expected you may get invalid data range messages or just exceed the display capability of a format.

Data _null_;
   x='06FEB1960:00:00:01'dt;
   put 'Numeric value of x is ' x best8.;
   put 'X is: ' x date9. ' with date9. format';
   put 'X is: ' x datetime19. ' with datetime9. format';
run;

The above shows that by 6 Feb 1960 the number of seconds exceeds the number of years that SAS date formats are expected to deal with. The **** when displayed with a partial date indicates the "year" the formatted encountered was greater than 9999 but less than 20,000. If you see all ********* for a date you have attempted to use a date that is year 20000 or greater. Which happens by 18Mar1960:00:00:01. 

View solution in original post

4 REPLIES 4
SASuserlot
Barite | Level 11

Thank you very much for quick response.

ballardw
Super User

SAS datetime values are numbers of seconds.

SAS Date values are numbers of days.

When treat a Date value as if it should be a Datetime then the actual value is way smaller than a datetime format, or function, expects.

Data _null_;
   x=today();
   put 'Numeric value of x is ' x best5.;
   put 'X is: ' x date9. ' with date9. format';
   put 'X is: ' x datetime9. ' with datetime9. format';
run;

When you accidentally use a datetime value where a date is expected you may get invalid data range messages or just exceed the display capability of a format.

Data _null_;
   x='06FEB1960:00:00:01'dt;
   put 'Numeric value of x is ' x best8.;
   put 'X is: ' x date9. ' with date9. format';
   put 'X is: ' x datetime19. ' with datetime9. format';
run;

The above shows that by 6 Feb 1960 the number of seconds exceeds the number of years that SAS date formats are expected to deal with. The **** when displayed with a partial date indicates the "year" the formatted encountered was greater than 9999 but less than 20,000. If you see all ********* for a date you have attempted to use a date that is year 20000 or greater. Which happens by 18Mar1960:00:00:01. 

SASuserlot
Barite | Level 11

Thank you for a detailed explanation.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1068 views
  • 4 likes
  • 3 in conversation