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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 255 views
  • 4 likes
  • 3 in conversation