Hello I need to run a dynamic report every week. In the report there are 12 user defined macro variables (m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11). For each customer there is one row with 13 fields: ID X_&m0 X_&m1 X_&m2 X_&m3 X_&m4 X_&m5 X_&m6 X_&m7 X_&m8 X_&m9 X_&m10 X_&m11 In the code there are 3 parts: part1- calculate % change in var X between each consecutive months part2-For each % change need to build indicator if there is %increase higher than 50%,or %decrease higher than 50%,or other. Part3-Need to calculate How many increases in more than 50% occurred and How many decreases in more than 50% occurred My question: Is there a way to write this long code by a more clever way? Please note that by writing a long code as I did there might be typing errors /*part1- Find % change of X between each 2 consecutive months*/
PCT_X&m1._&m0.=(X_&m1.-X_&m0.)/X_m0. ;
PCT_X&m2._&m1.=(X_&m2.-X_&m1.)/X_m1. ;
PCT_X&m3._&m2.=(X_&m3.-X_&m2.)/X_m2. ;
PCT_X&m4._&m3.=(X_&m4.-X_&m3.)/X_m3. ;
PCT_X&m5._&m4.=(X_&m5.-X_&m4.)/X_m4. ;
PCT_X&m6._&m5.=(X_&m6.-X_&m5.)/X_m5. ;
PCT_X&m7._&m6.=(X_&m7.-X_&m6.)/X_m6. ;
PCT_X&m8._&m7.=(X_&m8.-X_&m7.)/X_m7. ;
PCT_X&m9._&m8.=(X_&m9.-X_&m8.)/X_m8. ;
PCT_X&m10._&m9.=(X_&m10.-X_&m9.)/X_m9. ;
PCT_X&m11._&m10.=(X_&m11.-X_&m10.)/X_m10. ;
/*Part2*/
IF PCT_X&m1._&m0.>50% then Ind_X&m1._&m0.=1;
else IF PCT_X&m1._&m0.<-50% then Ind_X&m1._&m0.=-1;
else Ind_X&m1._&m0.=0;
IF PCT_X&m2._&m1.>50% then Ind_X&m2._&m1.=1;
else IF PCT_X&m2._&m1.<-50% then Ind_X&m2._&m1.=-1;
else Ind_X&m2._&m1.=0;
IF PCT_X&m3._&m2.>50% then Ind_X&m3._&m2.=1;
else IF PCT_X&m3._&m2.<-50% then Ind_X&m3._&m2.=-1;
else Ind_X&m3._&m2.=0;
IF PCT_X&m4._&m3.>50% then Ind_X&m4._&m3.=1;
else IF PCT_X&m4._&m3.<-50% then Ind_X&m4._&m3.=-1;
else Ind_X&m4._&m3.=0;
IF PCT_X&m5._&m4.>50% then Ind_X&m5._&m4.=1;
else IF PCT_X&m5._&m4.<-50% then Ind_X&m5._&m4.=-1;
else Ind_X&m5._&m4.=0;
IF PCT_X&m6._&m5.>50% then Ind_X&m6._&m5.=1;
else IF PCT_X&m6._&m5.<-50% then Ind_X&m6._&m5.=-1;
else Ind_X&m6._&m5.=0;
IF PCT_X&m7._&m6.>50% then Ind_X&m7._&m6.=1;
else IF PCT_X&m7._&m6.<-50% then Ind_X&m7._&m6.=-1;
else Ind_X&m7._&m6.=0;
IF PCT_X&m8._&m7.>50% then Ind_X&m8._&m7.=1;
else IF PCT_X&m8._&m7.<-50% then Ind_X&m8._&m7.=-1;
else Ind_X&m8._&m7.=0;
IF PCT_X&m9._&m8.>50% then Ind_X&m9._&m8.=1;
else IF PCT_X&m9._&m8.<-50% then Ind_X&m9._&m8.=-1;
else Ind_X&m9._&m8.=0;
IF PCT_X&m10._&m9.>50% then Ind_X&m10._&m9.=1;
else IF PCT_X&m10._&m9.<-50% then Ind_X&m10._&m9.=-1;
else Ind_X&m10._&m9.=0;
IF PCT_X&m11._&m10.>50% then Ind_X&m11._&m10.=1;
else IF PCT_X&m11._&m10.<-50% then Ind_X&m11._&m10.=-1;
else Ind_X&m11._&m10.=0;
/*Part3*/
Total_increases_More50PCT=SUM( (Ind_X&m1._&m0.=1),
( Ind_X&m2._&m1.=1),
( Ind_X&m3._&m2.=1),
( Ind_X&m4._&m3.=1),
( Ind_X&m5._&m4.=1),
(Ind_X&m6._&m5.=1),
(Ind_X&m7._&m6.=1),
( Ind_X&m8._&m7.=1),
( Ind_X&m9._&m8.=1),
( Ind_X&m10._&m9.=1),
( Ind_X&m11._&m10.=1));
Total_Decreases_More50PCT=SUM( (Ind_X&m1._&m0.=-1),
( Ind_X&m2._&m1.=-1),
( Ind_X&m3._&m2.=-1),
( Ind_X&m4._&m3.=-1),
( Ind_X&m5._&m4.=-1),
(Ind_X&m6._&m5.=-1),
(Ind_X&m7._&m6.=-1),
( Ind_X&m8._&m7.=-1),
( Ind_X&m9._&m8.=-1),
( Ind_X&m10._&m9.=-1),
( Ind_X&m11._&m10.=-1));
Total_NoChanges_MoreLess50PCT=SUM( (Ind_X&m1._&m0.=0),
( Ind_X&m2._&m1.=0),
( Ind_X&m3._&m2.=0),
( Ind_X&m4._&m3.=0),
( Ind_X&m5._&m4.=0),
(Ind_X&m6._&m5.=0),
(Ind_X&m7._&m6.=0),
( Ind_X&m8._&m7.=0),
( Ind_X&m9._&m8.=0),
( Ind_X&m10._&m9.=0),
( Ind_X&m11._&m10.=0));
... View more