DATA Step, Macro, Functions and more

Macro help creating a rolling 12 months

Reply
anonymous_user
Posts: 0

Macro help creating a rolling 12 months

Hi,

 

I need help in creating a macro around my simple query to report a rolling 12 months, anyone able to help me please?

 

%let mon=%sysfunc(intnx(month,%sysfunc(today()),&i.),yymmn6.);

%do i=1 %to 12;

data pootsDefs;

set mortbib.mort_&mon.(keep=mort snap bal);

 

run;

Frequent Contributor
Posts: 96

Re: Macro help creating a rolling 12 months

Posted in reply to anonymous_user

Try this code:

%macro month;
%do i=1 %to 12;
%let mon=%sysfunc(intnx(month,%sysfunc(today()),&i),yymmn6.);

data work.mort_&mon.;
set sashelp.class;
run;
%end;
%mend;

%month

Super User
Super User
Posts: 7,996

Re: Macro help creating a rolling 12 months

Posted in reply to anonymous_user

You can use the search functionality on this forum, there are hundreds of posts on this subject:

https://communities.sas.com/t5/forums/searchpage/tab/message?q=rolling+window

Ask a Question
Discussion stats
  • 2 replies
  • 184 views
  • 2 likes
  • 3 in conversation