Dear Professors, hope everyone is blessed with good health.

I use the following loop command for a number of regressions, the command is successfully executed, but after a certain level, it shows this error "insufficient observations"

I don't know how to drop those range of observations which are insufficient to be executed for regression.

Code:
clear
use ~\returns_stock_market_industry_calendar
drop if num_calendar<30
* drop if num_calendar<26


egen id = group(Stkcd year)
egen max_id = max(id)
local group_number = max_id


gen w=.
gen R2_SYNCH1 =.
gen R2_SYNCH2 =.
sort Stkcd Trdwnt
forvalue item =1(1)`group_number'{
    reg ret_stock ret_market ret_market_l1 ret_market_l2 ret_market_f1 ret_market_f2 if id==`item'
    predict e if id==`item',residual
    replace w = ln(1+e) if id==`item'    
    drop e
    reg ret_stock ret_market ret_market_l1 ret_ind ret_ind_l1 if id==`item'
    replace R2_SYNCH1 = e(r2) if id==`item'
    reg ret_stock ret_market ret_ind if id==`item'
    replace R2_SYNCH2 = e(r2) if id==`item'
    local progress `item'/`group_number'
    disp `progress'
}

Following error message:


insufficient observations
r(2001);

end of do-file

r(2001);

Thanks Professor