Hello all,

Below is an example of the data I am working with:

Code:
input float(year quarter miles)
2000 1 5
2000 1 2
2000 1 7
2000 2 3
2000 2 6 
2000 3 8
2000 3 9
2000 3 2
2000 3 1
2000 3 7
2000 4 8
2000 4 9
2000 4 4
2000 4 5
2000 4 3
2000 4 4
2001 1 2
2001 1 2
2001 2 3
2001 2 4
2001 3 5
2001 3 6
2001 3 4
2001 4 6
2001 4 3
2001 4 2
2001 4 5
2002 1 3
2002 1 7
2002 1 7
2002 1 4
2002 2 4
2002 2 6
2002 3 7
2002 3 5
2002 4 5
2002 4 3
2002 4 2
I would like to generate a new variable called "moving_average" that creates a moving average for the miles variable by year and quarter. For instance, 2000Q1 should have its own moving average, 2000Q2 should have its own moving average, etc. I would appreciate any assistance with this!

Thanks,
Anoush