Okay. This should be better proc sql; create table output_rolling as Select a.account_number , A.bal_date , Max(b.balance) as max_bal , Min(b.balance) as min_bal , Mean(b.balance) as avg_bal From HAVE as a Left join HAVE as b On a.account_number = b.account_number And intnx('month',a.bal_date,-11,'s') <= b.bal_date <= a.bal_date ; quit; so you join the data to itself and select all the balance between the current (12th) month and the 11 previous, for that account. note.... For the early period, the summary values will be based on an incomplete sample (1 month, then 2, 3,4, etc) until you have a full 12 months history for that account. It is easy to set up a simple count and reject any output that is based on less than 12 balances. Ask if you need help with that.
... View more