Hi there,

I am trying to estimate the discretionary accruals of the modified Jones model in Stata. However, I keep getting the error r(111) which says: variable term not found. I think something might be wrong with my variable fyear. These are the properties of the variable fyear: Type-double and Format-%ty.

This is the code I am running for to estimate the discretionary accruals:
gen Jones_2005_TAC2=.
forval y = 2014(1)2019{
forval i = 1(1) 22426{
display `i'
display `y'
reg TACC_2 term1 term 2 term3 if `i'==Industry_code & `y'==fyear, noconstant
predict r if `i'==Industry_code & `y'==fyear, resid
replace Jones_2005_TAC2=r if `i'==Industry_code & `y'==fyear
drop r
}
}

This is what Stata says when I run it:
. gen Jones_2005_TAC2=.
(22,458 missing values generated)

. forval y = 2014(1)2019{
2. forval i = 1(1) 22426{
3. display `i'
4. display `y'
5. reg TACC_2 term1 term 2 term3 if `i'==Industry
> _code & `y'==fyear, noconstant
6. predict r if `i'==Industry_code & `y'==fyear,
> resid
7. replace Jones_2005_TAC2=r if `i'==Industry_cod
> e & `y'==fyear
8. drop r
9. }
10. }
1
2014

variable term not found
r(111);


Hope someone can help me out. It is for my thesis!

Kind regards,
Sarah