So far I have this code, but I need to figure out a way to loop in for 24 months. data prev_month_0; set month_0; format prev_perc_0 BEST12.; age = age + 1; prev_perc_0 = perc_0; drop perc_0; run; proc sql; create table join_month_0 as select coalesce(t1.year,t2.year) as year, coalesce(t1.month,t2.month) as month, coalesce(t1.quarter,t2.quarter) as quarter, coalesce(t1.sex_cd,t2.sex_cd) as sex_cd, coalesce(t1.age,t2.age) as age, coalesce(t1.perc_0, 0) as perc_0, coalesce(t2.prev_perc_0, 0) as prev_perc_0 from month_0 as t1 full outer join prev_month_0 as t2 on t1.year = t2.year and t1.month = t2.month and t1.age = t2.age and t1.sex_cd = t2.sex_cd; quit; data month_1; set join_month_0; format perc_1 BEST12.; perc_1 = (11/12) * perc_0 + (1/12) * prev_perc_0; drop prev_perc_0; run;
... View more