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;
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.