Hi All, I have 3 sas datasets Mar19,Apr19 and May19. My task is to map last 6 months average monthly balances from 6 tables to my datasets. Also I want these mapped variables to be named as month1,month2,month3,month4,month5 and month6. I have written the below code to do the needful.However,I am stuck at naming the variables as month1 to month6 so that when I append these datasets I don't have to rename my columns. My code is giving me variable names as For Mar19 base - month1,month2,month3,month4,month5,month6 For Apr19 base - month2,month3,month4,month5,month6,month7(expected output month1,month2,month3,month4,month5,month6) For May19 base- month3,month4,month5,month6,month7,month8(expected output month1,month2,month3,month4,month5,month6) Can somebody please suggest me the solution.Thanks! %let base1=Mar19;
%let base2=Apr19;
%let base3=May19;
%let month1=Sep18;
%let month2=Oct18;
%let month3=Nov18;
%let month4=Dec18;
%let month5=Jan19;
%let month6=Feb19;
%let month7=Mar19;
%let month8=Apr19;
%let month9=May19;
%macro map;
%do i=1 %to 3;
%do j=&i %to %eval(&i+5);
proc sql;
create table &&base&i
as
select a.*,b.AMB as month&j from &&base&i a
left join monthly_balance_&&month&j b
on a.acct_no=b.acct_no;
quit;
%end;
%end;
%mend;
option mprint mlogic nosymbolgen;
%map;
... View more