Dear all,
I'm having a problem running a loop regression.
Basically, I have to run a regression for each industry and for each year. Calculating finally the residuals from this regression (it is the modified Jones model, for those people that are doing Accounting Research).

This is the code:
Code:
forval y=1989(1)2018{
  forval i=1(1)48{
    display `i'
    display `y'
    reg TA x1 x2 x3 if `i'== ffind & `y'== fyear & n_obs>=15, noconstant
    predict r if `i'== ffind & `y'== fyear n_obs>=15, resid
    replace modjones=r if `i'== ffind& `y'== fyear
    drop r
  }
}
As you can see there is a constraint (run the regression only if in that year and industry there are more than 15 observations).
The problem is that the loop stops immediately the first year with this message error:
Code:
1
1989
no observations
r(2000);
I browse for industry =1 and fyear =1989 and I noticed that there are 6 observations.
How can I stata tell to continue the loop and overcome the problem of no observations? Maybe replacing with missing values