Hi
Hope the code below will give you the idea:
data previous_all_months (drop=i);
length id 8;
array m {64} 8 m0 - m63;
do id=1 to 2;
do i= 1 to dim(m);
m(i)=i;
end;
output;
end;
run;
data new_month;
id=1;
m0=101;
output;
id=2;
m0=102;
output;
id=3;
m0=103;
output;
run;
proc sql;
/* create table current_all_months as*/
select
coalesce(p.id,n.id) as id
,n.m0
,p.m0 as m1
,p.m1 as m2
,p.m2 as m3
,p.m3 as m4
/* and so on until p.m62 as m63 */
from previous_all_months p full join new_month n
on p.id = n.id
order by id
;
quit;
Better would be to have the data organised in the following way:
ID, Date, Var.
Adding a new month would then simply be a Proc Append.
Getting rid of an old month would simply be a where clause 'where Date GT
HTH
Patrick