Hello, I have been trying to generate a variable that takes the five-year sum (from t-4 to to year t).

Code:
by gvkey: gen variable_t5= x+x[_n-1]+x[_n-2]+x[_n-3]+x[_n-4]
This is all I could come up with, however this will result in a lot of missing observations. Is there a better way to do this?