Hi,
I have a panel data set containing choosen financial data for thousands of companies. Some companies have data for 20 years, and some countries only have data for a few years. I have defined various ratios, such as Equity/Total assets, and want to calculate stable periods of given ratios for every firm. A condition is that the given ratio cannot change more than +/- 0.1 over a 10 year period. We want the first period to be from 2021 to 2012, next period 2020 to 2011 and so on.

I've tried to calculate the moving average using: tsset id YEAR > tssmooth ma ma1=ER, window(10 0 0), without luck. I get a error message saying: window() invalid -- invalid numlist has elements outside allowed range.

My questions are:

1. How can I calculate the moving average for 10 years for all firms individually?

2. How can only use the firms that have data for 10 years and changes in the range of +/- 0.1 over these 10 years. Meaning, I want to exclude all other firms in the calculations.

Hope someone can help me out here