proc sql; create table tab1 as select *, sum(tran_amt) as tot_expense, max(tran_amt) as max_expense from test group by trans_type; create table tab2 as select cust_id , trans_type from tab1 where max_expense = tran_amt; create table final_tab as select a.*,b.cust_id as cust_with_max_exp from tab1 a, tab2 b where a.trans_type = b.trans_type; quit;
... View more