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.
Its for each following month, hope the table below makes it clear.
I can lag "Var." by lag12 and find the required average. But then I also need to reset my first 12 values for each firm because once I lag by 12 then ABC values will overlap with XYZ. This is where I am stuck, 'How do I reset the first 12 values for each firm?'.