Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Macro Loops by Month

Here's a macro which executes some code for each month in an interval. Months are assumed to be specified in the format YYYYMM.

%macro monthly(first,last); 
  %do mon=&first %to &last;
    %if %substr(&mon,5)=13 %then 
      %let mon=%eval(%substr(&mon,1,4)+1)01;
    %put Processing month &mon; 
  %end; 
%mend monthly; 

Invoking the macro thus:

%monthly(200311, 200402); 

yields the following output;

Processing month 200311 
Processing month 200312 
Processing month 200401