BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kajal_30
Quartz | Level 8

Hi Team,

 

I am setting up a date macro variable in my program as below:

1. if I put  %let date = 01may18 ;

    it gets resolve to 01may2018

2. If I put %let date = 01may19 ;

    it gets resolve to 01may2019

3. if I put %let date = 01may20;

    it gets resolve to 1920 which I am expecting to be 2020 

May I know which option in the program will give me correct results?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Please use the below option and then execute the macro variable

 

SAS software treats the year 2000 like any other leap year. If you use two-digit year numbers for dates, you'll probably need to adjust the default setting for the YEARCUTOFF= option to work with date ranges for your data, or switch to four-digit years. The following program changes the YEARCUTOFF= value to 1950. This change means that all two digit dates are now assumed to fall in the 100-year span from 1950 to 2049.

 

options yearcutoff=1950;

 

 

Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

Please use the below option and then execute the macro variable

 

SAS software treats the year 2000 like any other leap year. If you use two-digit year numbers for dates, you'll probably need to adjust the default setting for the YEARCUTOFF= option to work with date ranges for your data, or switch to four-digit years. The following program changes the YEARCUTOFF= value to 1950. This change means that all two digit dates are now assumed to fall in the 100-year span from 1950 to 2049.

 

options yearcutoff=1950;

 

 

Thanks,
Jag
kajal_30
Quartz | Level 8

Thank you so much it worked

Kurt_Bremser
Super User

There's an extremely simple solution:

USE FOUR-DIGIT YEARS!!!

I am once again astonished that there are still people who, after the Y2k scare, are ***redacted*** to work with two-digit years, and expect anything other than problems.

 

Next, date values are best stored in raw form in macro variables:

 %let date=%sysfunc(inputn(2020-05-01,yymmdd10.));

As you now only need to use &date (no quotes) in your code.

ghosh
Barite | Level 11
%let date= '01may2019'd;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1204 views
  • 1 like
  • 4 in conversation