bysort id : asrol ebitda, gen(sd_ebitda) stat(sd) window(year 5) min(4) xf(focal)
Reply To: rolling command panel data
The code is the same as used in my earlier reply. That calculates the moving average of the last 4 years. If you want to exclude the current year, then the code would be: