Dear all,
Maybe you have a quick solution for this:
I would like to create a timeseries for 48 months. Always get month end by providing a start date via a macro variable. My code below doesn't work. Any ideas?
So, Reporting_Date should look like:
31jan2020
29feb2020
31mar2020
...
%let startdate = '01jan2020'd;
data test;
do t = 1 to 48;
Reporting_Date = intnx('month', '&startdate.', t-1, 'E');
output;
end;
run;
Thanks!
First of all, macro variables are not resolved when enclosed in single quotes. Second, you already have quotes in your macro variables, so that won't work either. Third, without a date format your results will not display right.
So do this:
%let startdate = 01jan2020;
data test;
format Reporting_Date yymmddd10.;
do t = 1 to 48;
Reporting_Date = intnx('month', "&startdate."d, t-1, 'E');
output;
end;
run;
First of all, macro variables are not resolved when enclosed in single quotes. Second, you already have quotes in your macro variables, so that won't work either. Third, without a date format your results will not display right.
So do this:
%let startdate = 01jan2020;
data test;
format Reporting_Date yymmddd10.;
do t = 1 to 48;
Reporting_Date = intnx('month', "&startdate."d, t-1, 'E');
output;
end;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.