BookmarkSubscribeRSS Feed
Tboat
Fluorite | Level 6

I need help figuring out why my output year date value shows as the year 2081. I need the year to be 2021 or 2022. Please help. Thanks.
3 REPLIES 3
ballardw
Super User

Show the actual numeric value of the variable with a BEST16. format applied.

Show/describe how you show the year value you say is incorrect.

 

Typically this sort of thing comes from either an incorrectly built date value, something not actually a date but you think it is, or values out side of your expected range.

Reeza
Super User
What code generated the date/year?
Tom
Super User Tom
Super User

Have you accidentally applied a SAS date format to the number that Excel uses to store dates?  Excel and SAS use different starting days for counting the number of days.

You can correct an Excel date into a SAS date by adding the date 30DEC1899 (which will be a negative number since SAS counts dates from 1960).

284   data _null_;
285     date=mdy(12,31,2020);
286     put date= date9. date=comma12. ;
287     date=mdy(1,1,2081);
288     put date= date9. date=comma12. ;
289     date=date+'30dec1899'd;
290     put date= date9. date=comma12. ;
291   run;

date=31DEC2020 date=22,280
date=01JAN2081 date=44,196
date=31DEC2020 date=22,280

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 671 views
  • 0 likes
  • 4 in conversation