Lag rolling averages

Reply
New Contributor
Posts: 2

Lag rolling averages

Hi all,

I have a question regarding calculating a rolling average. Let's say that I have a dataset contains date, stock identifier, and daily volume turnover. For each stock and for each date, I want to calculate the average of daily volume turnover over the previous six months. For example, if the date says 2013-Oct-24, then I want to calculate the average of daily turnover from 2013-April-01 to 2013-Sep-30 using all available observations during this period (as trading days are fewer than calendar days, or the data may starts at 2013-August-01).

I have attached a sample dataset. permno is the stock identifier, and daily_turn is the daily volume turnover. 

Thanks for the help.

Attachment
Super User
Posts: 17,815

Re: Lag rolling averages

Do you have SAS/ETS? If so look into Proc Expand

New Contributor
Posts: 2

Re: Lag rolling averages

I know that I could use proc expand to calculate moving averages with specified lookback period. But for my case where the lookback period is not specified, how does it work?

Super User
Posts: 17,815

Re: Lag rolling averages

You said the lookback period was 6 months, what am I missing?

Ask a Question
Discussion stats
  • 3 replies
  • 176 views
  • 0 likes
  • 2 in conversation