Hello Kurt. Thank you for responding. Because I always have a "top 10" ive just created this data work.Split_&Pos_Entry; set work.Top10_trans_&Pos_Entry; by IEE; retain ID 0; if first.IEE then ID = ID + 1; run; this has given me a data set with an ID 1 to 10 thus grouping each of the IEE's I "think" im ont he right track here. what i now need to happen is if id = 1 then output to DATAset_1 if id = 2 then output to DATAset_2 %macro IEEFraud(Pos_Entry= ); Here's my full current code if this helps me explain better proc sql outobs=10; create table Top10_&Pos_Entry as select Distinct MERCHANT_CATEGORY_XCD, TRANSACTN_POSTING_ETRY_XFLG, count(MERCHANT_CATEGORY_XCD) as Count, sum(TRANSACTION_AMT) as Sum_Total from Data.GET_TRANSACTIONS Where TRANSACTN_POSTING_ETRY_XFLG = "&Pos_Entry" and TRANSACTION_FRAUD_TYPE_CD = "CONFIRMED_FRAUD" Group by 1 Order By Sum_Total DESC ; quit; proc sql; create table Top10_Trans_&Pos_Entry as select Auth.FI_TRANSACTION_ID, Auth.PAN, Auth.TRANSACTION_dttm, Auth.MERCHANT_CATEGORY_XCD as IEE, Auth.TRANSACTION_AMT, Auth.TRANSACTN_POSTING_ETRY_XFLG, Auth.AUTH_SECONDARY_VERIFY_XCD as Secure, Auth.Decision_XCD as Host_Decision, Auth.MODEL_SCR, Auth.TRANSACTION_FRAUD_TYPE_CD, case when TRANSACTION_FRAUD_TYPE_CD = "CONFIRMED_FRAUD" then 1 else 0 end as Fraud_Flag from Data.GET_TRANSACTIONS as auth Inner join work.Top10_&Pos_Entry as IEE on auth.MERCHANT_CATEGORY_XCD = IEE.MERCHANT_CATEGORY_XCD and auth.TRANSACTN_POSTING_ETRY_XFLG = IEE.TRANSACTN_POSTING_ETRY_XFLG order by IEE; ; quit; data work.Split_&Pos_Entry; set work.Top10_trans_&Pos_Entry; by IEE; retain ID 0; if first.IEE then ID = ID + 1; run; %mend IEEFraud; %IEEFraud(Pos_Entry= E) %IEEFraud(Pos_Entry= K) %IEEFraud(Pos_Entry= S) %IEEFraud(Pos_Entry= F) %IEEFraud(Pos_Entry= V)
... View more