The code roughly looks like this. %macro account ();
PROC SQL;
create table temp.base(
var1 length=8,
var2 length=8,
var3 length=8,
var4 length=8,
var5 length=8,
var6 length=8,
var7 length=8,
);
QUIT;
%do i = 0 %to &number.;
DATA _NULL_;
*--- determine year-month of loop in sas date;
YYYY_MM_SAS = INTNX("MONTH", "&MORT_S_DATE."D, &I.);
CALL SYMPUTX ('YYYY_MM_SAS', YYYY_MM_SAS);
*--- determine month of loop in YYYY_MM format;
CALL SYMPUTX ('YYYY_MM', tranwrd(put(YYYY_MM_SAS, yymmd8.),"-","_"));
*--- determine month of loop in YYYYMM format;
CALL SYMPUTX ('YYYYMM', put(YYYY_MM_SAS, yymmn6.));
RUN;
DATA add&YYYY_MM._PERF;
LENGTH
var1 length=8
var2 length=8
var3 length=8
var4 length=8
var5 length=8
var6 length=8
var7 length=8
;
SET arrears_credit (keep=var1 var2
where=(year_month=&YYYYMM.));
SET ACCOUNT_&YYYY_MM. (KEEP = var 1 var3 var4 var5 var6 var7
)
KEY = var1 / UNIQUE;
RUN;
PROC APPEND BASE = base DATA = add&YYYY_MM._PERF;
RUN;
PROC SQL;
DROP TABLE add&YYYY_MM._PERF;
QUIT;
%end;
%mend account;
... View more