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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 885 views
  • 0 likes
  • 4 in conversation