New Contributor
Posts: 2

# calculating running average for Last 1 day, last 7 days and last 15 days ,,

Dear experts,

I need your help to calculate running avearages of transaction amount (tran_amt)backward from current day (t) to last 1day , last7days and last15 days  by account number (acc_id). please use the below data and sample calculations are shown in the columns Avg_L1D ( average(t + t-1), Avg_L7d (average( t, t-1,t-2,t-3,t-4,t-5,t-6,t-7) ) if any of lag transactions missing it shoud discard say if t-6 is missing then average will be average(t,t-1,t-2,t-3,t-4,t-5,t-7) etc. similarly for Avg_L15D...

CSV file attached for rawdata and the sample calcuation

kind regards,

Raj

PROC Star
Posts: 1,592

## Re: calculating running average for Last 1 day, last 7 days and last 15 days ,,

If you could please explain the calculation in terms of your numbers in the sample rather than algebraically, I would like to attempt .

New Contributor
Posts: 2

## Re: calculating running average for Last 1 day, last 7 days and last 15 days ,,

Dear sir, I explained the logic in the attached excel sheet
Posts: 4,687