Apologies. Can ignore the previous coding i asked. The issue seems like appear after the %datecreate macro. If only run until %setting then it works. However, when run one more macro (i.e. %datecreate) then it won't auto generate the second and third run. So, i have create delete specific global macro. %macro repeat(n);
%do i = 1 %to &n.;
%if &i. = 1 %then
%do;
%let month = 4;
%let lag = 2;
%end;
%if &i. = 2 %then
%do;
%let month = 7;
%let lag = 2;
%end;
%if &i. = 3 %then
%do;
%let month = 4;
%let lag = 1;
%end;
%month_setting;
%setting;
%datecreate;
%deleteALL;
%end;
%mend;
%repeat(3);
%macro month_setting;
%global begin end;
%if %sysevalf(&lag = 2) %then
%do;
%let begin = "%sysfunc(intnx(month,%sysfunc(inputN(&period.01,yymmdd10.)),-&month.),date9.)"d;
%let end = "%sysfunc(intnx(month,%sysfunc(inputN(&period.01,yymmdd10.)), +&lag.),date9.)"d;
%end;
%else %if %sysevalf(&lag = 1) %then
%do;
%let begin = "%sysfunc(intnx(month,%sysfunc(inputN(&period.01,yymmdd10.)),-&month.+1),date9.)"d;
%let end = "%sysfunc(intnx(month,%sysfunc(inputN(&period.01,yymmdd10.)), +&lag.+1),date9.)"d;
%end;
%let end_YM = %sysfunc(inputn(%sysfunc(substr(%sysfunc(putn(&end., yymmddn8.)),1, 6)), 6.));
%let beg_YM = %sysfunc(inputn(%sysfunc(substr(%sysfunc(putn(&begin., yymmddn8.)),1, 6)), 6.));
%mend;
/*macro sample*/
%macro setting;
Data working.M&Month._Setting;
month = &month.;
lag = &lag.;
begin = put(&begin.,yymmddn8.);
end = put(&end.,yymmddn8.);
run;
%mend;
%macro datecreate;
%global dif;
%let dif = %sysfunc(intck(MONTH,&begin,&end));
%do i= 1 %to &dif;
%global date_&i;
%let date_&i=%sysfunc(intnx(month,&begin,&i,B),yymmn6.);
%put &&date_&i;
%end;
%mend;
%macro deleteALL;
options nonotes;
%local vars;
proc sql noprint;
select name into: vars separated by ' '
from dictionary.macros
where scope = 'GLOBAL' and (name contains 'DATE_' or name in ('MONTH', 'LAG', 'BEGIN','END', 'BEG_YM', 'END_YM', 'DIF'));
quit;
%symdel &vars;
options notes;
%put NOTE: Macro variables deleted.;
%mend;
But, the above coding not working also. It didn't pop any errors. However, it will not generate the results for Month 7 + Lag 2 and Month 4 + lag 1.
... View more