Hi,
I'm running a cross- sectional regression based on modified Jones model to calculate discretionary accruals. The problem is the component drev has negative sign but it should be positive. Here is all my commands. I appreciate if you help me.

destring company_fkey, replace

drop if at==. | at<=0

destring sic, replace
replace sic=sich if sich!=.
drop if sic==.

drop if sic>5999 & sic<7000

duplicates drop company_fkey fyear, force

tsset company_fkey fyear

gen lagta=l.at

gen tacc=(ibc-oancf)/lagta

gen drev=(d.sale-d.rect)/lagta

gen inverse_a=1/lagta

gen ppe=ppegt/lagta


drop if tacc==.
drop if drev==.
drop if ppe==.

tostring sic, replace

gen l=length(sic)

tabstat l, by(l) stats(N)
gen zero="0"
egen help=concat(zero sic) if l==3
replace sic=help if l==3
drop l help zero
gen sic2=substr(sic,1,2)
egen sic2id=group(sic2 fyear)
sort sic2id
egen count=count(sic2id), by(sic2id)

drop if count<20

drop count sic2id

egen sic2id=group(sic2 fyear)


sum tacc,d
replace tacc=r(p1) if tacc<r(p1)
replace tacc=r(p99) if tacc>r(p99) & tacc!=.

sum drev,d
replace drev=r(p1) if drev<r(p1)
replace drev=r(p99) if drev>r(p99) & drev!=.
*inverse lagged total assets (this is never negative thereofre just 99%)
sum inverse_a,d
replace inverse_a=r(p99) if inverse_a>r(p99) & inverse_a!=.
*ppe (this is the sam above just 99%)
sum ppe,d
replace ppe=r(p99) if ppe>r(p99) & ppe!=.

gen dac=.
gen r2a=.

gen b1=.
gen b2=.
gen b3=.

sum sic2id
local k=r(max)
forvalues i=1(1)`k'{
qui reg tacc inverse_a drev ppe if sic2id==`i'
qui predict res if sic2id==`i', res
qui replace dac=res if sic2id==`i'
qui replace r2a=e(r2_a) if sic2id==`i'
qui replace b1=_b[inverse_a] if sic2id==`i'
qui replace b2=_b[drev] if sic2id==`i'
qui replace b3=_b[ppe] if sic2id==`i'
qui drop res
di `i' " / " `k'
}

tabstat r2a dac b1 b2 b3, stats(N mean p25 median p75) columns(statistics)