Sorry but this way it does not work. Inside having condition, the value of min(b.factor1-a.percentile) cannot be computed corrected as every time during the substraction and with min () condition the factor_1 will be substracted with the highest value ie. of P_100 (value 507) which yeild a value -455 and thus every time P_100 percentile band will be selected. Example - Factor 1 P_0 P_1 P_2 P_42 P_43 P_75 P_76 P_77 P_97 P_98 P_99 P_100 152 -431 -246 -209 26 30 149 154 159 320 346 379 507 28 -431 -246 -209 26 30 149 154 159 320 346 379 507 In the above table, the correct percentile band of 152 should be P_75 (value 154) and 28 should be P_43 but using your mentioned query it gives Factor 1 _NAME_ COL1 152 P_100 507 28 P_100 507 What I need is comparing the value of factor_1 with each percentile value and find the percentile bucket in which the factor_1 value is less than or equal to. Why I have been using array is bcoz I have been used to Object oriented language and with array its easy to compare Factor_1 value iteratively with every single percentile value and saving the index where it matches -- this is how I am doing and as it is a part of a process chain it needs to be run within pre-defined macro SAS code for calculating the percentile band but does not work under macro as I am unable to figure out arrays inside macro - data data_band2 ; set data; array p{*} P_0 - P_100; score_perc = 0; do i = 1 to 100; if Factor_1 > p{i} and Factor_1 <= p{i+1} then score_perc = i; end; if Factor_1 < P_1 then score_perc=1; run;
... View more