If I had a choice, like Scott suggested, I would rather see you change the data structure, but not given the option the macro was fun to write. See if this is close to the direction that you are going. The outer %DO loop in the macro would not be needed in production and only appears here because I am stepping through all the months at one time.
[pre]data jan;
outlet=345;
sales1=1;
run;
data feb;
outlet=345;
sales1=2;
run;
data mar;
outlet=345;
sales1=3;
run;
data apr;
outlet=345;
sales1=4.4;
run;
/* Example target code to be generated by the macro SALESMO*/
/*data totjan;*/
/* set jan;*/
/* run;*/
/*data totfeb;*/
/* merge totjan(rename=(sales1=sales2))*/
/* feb;*/
/* by outlet;*/
/* run;*/
/*data totmar;*/
/* merge totfeb(rename=(sales2=sales3 sales1=sales2))*/
/* mar;*/
/* by outlet;*/
/* run;*/
/*proc print data=totmar;*/
run;
%macro salesmo(mo=jan);
%local monum molast i m;
%let monum = %sysfunc(month(%sysfunc(inputn(&mo.2010,monyy7.))));
%*put monum &monum;
%do I = 1 %to &monum;
data tot&mo;
%if i=1 %then %do;
%* The month is january;
set &mo;
%end;
%else %do;
%* Determine the name of the previous month;
%let molast = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(mdy(&i,1,2010)),-1)),monname3.));
merge tot&molast(rename=(
%do m=&i %to 2 %by -1;
%* build the rename pairs in descending order;
sales%eval(&m-1)=sales&m
%end;
))
%* Read the current months data;
&mo;
by outlet;
%end;
run;
%end;
%mend salesmo;
%salesmo(mo=apr)
proc print data=totapr;
run;
[/pre]
For renaming the variables, which is really the heart of your question, this solution takes advantage of the RENAME= options execution properties.
[pre] merge totfeb(rename=(sales2=sales3 sales1=sales2))[/pre]
here sales2 is renamed to sales3 before sales1 is renamed to sales2