Hi Again, I already posted a question here similar to this. But this is something very trick for me which I didn't get the solution. data have; input a2 $ a1 $12. a b; cards; VA IME_PREM_ADJ 11 100 VA IME_PREM_ADJ 12 102 VA IME_PREM_NON 11 101 VA IME_PREM_ADJ 13 101 WVA IME_PREM_RES 11 105 VA IME_PREM_RES 3 102 VA IME_PREM_NON 2 200 VA IME_ANNUITIE 3 205 WVA IME_ANNUITIE 4 501 ; run; proc sort data=have out=haveSrt; by a2 a1 descending a; run; This is a sample data with 4 columns and few observations, in my original data I have 20+ columns and crores of data. what I need is, sum b column based on (b>=b), but the group by should be maintained, the issue is as there are many columns we cn't predict which column we have to use for first. for doing the sum. is there any ways to get this done? The output should lokks like : a2 a1 a b b_sum VA IME_ANNUITIE 3 205 205 VA IME_PREM_ADJ 13 101 303 VA IME_PREM_ADJ 12 102 202 VA IME_PREM_ADJ 11 100 100 VA IME_PREM_NON 11 101 301 VA IME_PREM_NON 2 200 200 VA IME_PREM_RES 3 102 102 WVA IME_ANNUITIE 4 501 501 WVA IME_PREM_RES 11 105 105 here taking an example of a2=VA and a1=IME_PREM_ADJ the column a has values 13,12,11 so, the first row of 13 will be b_sum=b(13)+b(12)+ b(11) because 13>=12 and 11, likewise for the row of 12, b_sum=b(12)+b(11). But, Please make sure about the multiple columns in the by group. Thanks, Chithra
... View more