Hi all. I'm studying the relationship between restatements and firms' earnings management behaviour. I'm using DA to capture such behaviour. The sample period is 2010-2019. Let's say a firm restated in 2015, I'm interested in its DA in period 13, 14, 16, 17 (two years before and two years after). Data in t-3 (2012 in this case) and t (2015) is also included as this is a panel data. I have all the data transformed into the delta form, it is just the last step that I can never get right. I attached a file in which all the data are processed and are ready for the last step.

below is the code I first used:

​​​​​​
Code:
gen Jones=.
forval y = 2010 (1) 2019{
forval i = 1 (1) 136{
display `i'
display `y'
reg scaled_TACC inverse_lagTA term2 scaled_PPE if `i' == Industryid&`y'== YEAR, noconstant
predict r if `i'== Industryid&`y'== YEAR, resid
replace Jones=r if `i'== Industryid&`y'== YEAR
drop r
}
}
But this gives me nothing and STATA keeps showing r451. Then I reformed it and added a line:

Code:
​​​​​​ gen Jones=.
forval y = 2010(1)2019{
   forval i = 1(1) 136{
      display `i'
      display `y'
      capture noisily{
         reg scaled_TACC inverse_lagTA term2 scaled_PPE if `i'== Industryid & `y'== YEAR, noconstant
         predict r if `i'== Industryid & `y'== YEAR, resid
         replace Jones_2005_TAC2=r if `i'== Industryid & `y'== YEAR 
         drop r
      }
   }
}
Then the code starts running but, still, I have quite a lot of missing values in my result. Really hope someone could help me. Thanks in advance!!