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
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.
Applying a datetime format to a date value will usually end with a displayed date on 1960-01-01, because most dates used lie between 0 and 86400.
Thank you very much for quick response.
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.
Thank you for a detailed explanation.
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.
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.