I need to calculate annual average, ie, the average of today’s value with the value 12 months back. If I have a variable with monthly observations, how can I do that? Please note that I am working with multiple stocks.
An example is given below.
Date Var. Avg.
Jan-08 1
Feb-08 2
Mar-08 3
Apr-08 4
May-08 5
Jun-08 6
Jul-08 7
Aug-08 8
Sep-08 9
Oct-08 10
Nov-08 11
Dec-08 12
Jan-09 13 (1+13)/2
I know that I can do this using lag12 function, but then I am not able to figure out how to reset the first 12 observations for each stock.
Any help would be really appreciated. Have been stuck on this for a while