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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: