Try this. Need to do some modifications at your end. data have; input CUSTOMER_ID transaction_date date9.; format transaction_date date9.; cards; 440767 13-Jan-07 440767 5-Jan-12 440767 3-Jun-09 440767 17-Jan-12 440767 9-Apr-09 440767 10-Aug-08 1795023 10-Jul-12 1795023 11-Aug-11 1795023 30-Nov-09 1795023 9-Jan-12 1795023 20-Jan-11 1795023 10-Apr-09 1795023 2-Nov-11 1795023 8-Feb-12 1795023 17-Aug-11 1795023 19-Nov-13 3627695 29-May-06 3627695 15-May-03 3627695 23-Mar-15 3627695 18-May-06 ; run; proc sort data=have; by CUSTOMER_ID transaction_date; run; data want; set have; by customer_id ; retain transaction_date; dt=lag(transaction_date); avr_Days_Betw_Each_trans=mean(intck('day',transaction_date,dt)); AvrDaysBetw_trans_sixMonth=mean(intck('QTR2',transaction_date,dt)); avrDaysBetw_trans_year_Intervals=mean(intck('year',transaction_date,dt)); if first.customer_id then ftran=transaction_date; if last.customer_id then ltran=transaction_date; avr_Days_first_last_trans=mean(intck('day',ftran,ltran)); format dt ftran ltran date9.; drop ftran ltran dt; run; proc sql; select avg(avr_Days_Betw_Each_trans) as avr_Days_Betw_Each_trans, avg(AvrDaysBetw_trans_sixMonth) as AvrDaysBetw_trans_sixMonth, avg(avrDaysBetw_trans_year_Intervals) as avrDaysBetw_trans_year_Intervals, avg(avr_Days_first_last_trans) asavr_Days_first_last_trans from want; quit; Rgds, Vish
... View more