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?
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;
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;
Thank you so much it worked
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.
%let date= '01may2019'd;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.