Hi @sas_user_1001
While I see you have already accepted a solution, here is an approach that gives the ability to have variable growth rates for future years. Yet another implementation that utilizes two dimensional array.
data have;
input year month x_var;
datalines;
2020 1 5
2020 2 10
2020 3 15
2020 4 25
;
run;
data want(KEEP= year month x_var gr_pct);
if (0) then SET have;
array x{20:24,1:4} 8 _temporary_; /* Change these dimensions to fit your needs */
array gr{5} 3 gr1-gr5 (0, 0.05, 0.05, 0.03, 0.01); /* Annual growth rate */
/* Load the 2020 (have) data values */
do _n_=1 by 1 until(eof);
set have end=eof;
x{20,_n_} = x_var;
end;
/* ---------------------------- */
/* Process future forecast data */
/* ---------------------------- */
gi = 1; /* growth rate index */
do y=21 to hbound1(X);
gi+1;
do m=lbound2(X) to hbound2(X);
x{y,m} = x{(y-1),m} * (1 + gr{gi});
put x{y,m} =;
end;
end;
/* ------------------------ */
/* Generate desired output */
/* ------------------------ */
gi = 0;
do y=lbound1(X) to hbound1(X);
gi+1;
do m=lbound2(X) to hbound2(X);
year = 2000+y;
month = m;
x_var = x{y,m};
gr_pct = gr{gi};
output;
end;
end;
stop;
run;
Hope this helps,
Ahmed
... View more