Hello all, I want to create a variable which is defined as the annual decile rankings of the three-year average of total loss recognition timeliness. I want to have an average for each year starting from 2002 to 2018.

I tried to create the following command but it says invalid syntax:

egen AVR2002= rmean (Converse Converse [_n-1] Converse [_n-2]) if year==year[_n-1]+1

Would appreciate your help regarding that.