BookmarkSubscribeRSS Feed
rajashekarmt
SAS Employee

 

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

 

thanks for your help

 

kind regards,

Raj

 

 

 

 

 

3 REPLIES 3
novinosrin
Tourmaline | Level 20

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

rajashekarmt
SAS Employee
Dear sir, I explained the logic in the attached excel sheet
Patrick
Opal | Level 21

@rajashekarmt wrote:
Dear sir, I explained the logic in the attached excel sheet

@rajashekarmt

Great that you've posted some data but you will also need to add some explanation in words how the logic works and not expect us to work this all out based on the numbers you've provided.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 783 views
  • 0 likes
  • 3 in conversation