Yes, unfortunately a common issue this one, and all caused by the fact that date is a part of the dataset name. Think how much simpler the world would be if you had one dataset, with a fixed name and structure, and a column which contained the date, no looping or appending, just simple data. I don't know where this thinking came in but it does seem to account for more than half the questions on this forum.
Anyways (not tested):
%let mort_s_date=12JAN2014;
%let number=5;
data _null_;
call execute('data base;');
do i=1 to &number.;
tmp=intnx("month","&mort_s_date."d, &i.);
call execute('set arrears_credit (keep=var1 var2 where=(yearmonth='||put(tmp,yymm6.)||'));');
call execute('set account_'||put(year(tmp),z4.)||'_'||put(month(tmp),z2.)||' (keep=var1 var3 var4 var5 var6 var7);');
end;
run;
... View more