Hi Reeza, Thanks a lot for pointing out this method. It worked out for me. Below are the code I extended for my purposes. *Sample output for change variables months; data wantFinal (drop=v:); set have; /*last_3month*/ array l_3(3) v1 v2 v3; do i=-3, -2, -1; var=put(intnx('month', last_date, i), monyy5.); l_3(i+4)=vvaluex(var); end; month3l_mean=mean(of l_3(*)); month3l_std=std(of l_3(*)); *previous 3 month; array p_3(3) v4 v5 v6; do i=-6,-5,-4; var=put(intnx('month', last_date, i), monyy5.); p_3(i+7)=vvaluex(var); end; month3p_mean=mean(of p_3(*)); month3p_std=std(of p_3(*)); *last 6 month; array l_6(6) v61 v62 v63 v64 v65 v66; do i=-6,-5,-4,-3,-2,-1; var=put(intnx('month', last_date, i), monyy5.); l_6(i+7)=vvaluex(var); end; month6l_mean=mean(of l_6(*)); month6l_std=std(of l_6(*)); *previous 6 month; array p_6(6) v67 v68 v69 v610 v611 v612; do i=-12,-11,-10,-9,-8,-7; var=put(intnx('month', last_date, i), monyy5.); p_6(i+13)=vvaluex(var); end; month6p_mean=mean(of p_6(*)); month6p_std=std(of p_6(*)); *last 12 month; array l_12(12) v121 v122 v123 v124 v125 v126 v127 v128 v129 v1210 v1211 v1212; do i=-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1; var=put(intnx('month', last_date, i), monyy5.); l_12(i+13)=vvaluex(var); end; month12l_mean=mean(of l_12(*)); month12l_std=std(of l_12(*)); *previous 12 month; array p_12(12) v1210 v1220 v1230 v1240 v1250 v1260 v1270 v1280 v1290 v12100 v12110 v12120; do i=-24,-23,-22,-21,-20,-19,-18,-17,-16,-15,-14,-13; var=put(intnx('month', last_date, i), monyy5.); p_12(i+25)=vvaluex(var); end; month12p_mean=mean(of p_12(*)); month12p_std=std(of p_12(*)); run;
... View more