Hi! Thanks for your time and effort! Unfortunately, this doesn't work. See the code below I'm using now:
%MACRO RUNYYMM2(BEG_YYMM,END_YYMM);
%LET BEG_YY = %EVAL(%SUBSTR(&BEG_YYMM,1,4) * 1);
%LET BEG_MM = %EVAL(%SUBSTR(&BEG_YYMM,5,2) * 1);
%LET END_YY = %EVAL(%SUBSTR(&END_YYMM,1,4) * 1);
%LET END_MM = %EVAL(%SUBSTR(&END_YYMM,5,2) * 1);
*GET ROUNDS OF THE LOOP;
%LET L=%EVAL((&END_YY-&BEG_YY)*12 + (&END_MM - &BEG_MM) + 1);
*GENERATE THE DATE CONSTANTS, THESE ARE GLOBAL VARIABLES;
%DO I = 1 %TO &L;
DATA _NULL_;
/* Ways to generate date MACRO VARIABLES*/
CALL SYMPUT('YYYYMM', PUT(INTNX('MONTH',MDY(&BEG_MM,1,&BEG_YY),&I - 1,'B'),YYMMN6.));
CALL SYMPUT('MMDDYYYY', "'"||PUT(INTNX('MONTH',MDY(&BEG_MM,1,&BEG_YY),&I - 1,'E'),MMDDYYN8.)||"'");
run;
%let Jaar=%SUBSTR(&YYYYMM,1,4);
%let Maand=%SUBSTR(&YYYYMM,5);
*PUT THE DATE CONSTANTS IN THE LOG;
%PUT "YYYYMM IS " &YYYYMM;
%PUT "MMDDYYYY IS " &MMDDYYYY;
%PUT "THIS IS LOOP " &I;
Data test;
set "N:\Report\&jaar\&maand\report_test.sas7bdat";
run;%end;
%mend ;
%RUNYYMM2(201007, 201010);
I had to remove the loop statement out of the latest data statement, otherwise there were 2 loops (one at the beginning and one in the data statement --> resulting in 9 months in stead of 3). But... Using 1 or 2 loops (2 loops with the statement you've given) didn't result in a set statement that didn't overwrites the old file.
Right now, the code runs almost perfect, except all months are overwritten... So I only get the latest month in my dataset in stead of the 3 months. Does anyone know if there's a statement that really concatenates? Or do I need to work with IF statements?
Thanks for the answer!