Hi all. I am trying to make a table with esttab using output from margins. I think this will be challenging without having the data, but I thought I'd post here in case I've missed an obvious problem. The code below should produce a table with 10 columns of results. Instead it cuts it off at 8, and I cannot figure out why. Any ideas? Sorry if my code is hard to read, I couldn't figure out how to use indents here.
Code:

local j 1
est store clear
foreach i in resp_age tec_index mobility_idx_b emp_idx_b own_kids_under12_b hhsize_m resp_edu_b lk_score_p_b train_dist migrant_b {

qui logit complete1 c.resp_age##i.TT c.tec_index##i.TT c.mobility_idx_b##i.TT c.emp_idx_b##i.TT c.own_kids_under12_b##i.TT c.hhsize_m##i.TT c.resp_edu_b##i.TT c.lk_score_p_b##i.TT c.train_dist##i.TT i.migrant_b##i.TT if trainee == 1, cluster(CoopSN)

margins, dydx(`i') over(TT) post
est sto m`j'

cap noi lincom _b[`i':0.TT] - _b[`i':1.TT]

if _rc == 0 {
local diff_se: display %10.3f r(se)
scalar p = 2*(1-normal(abs(r(estimate)/r(se))))
if scalar(p) >= 0.10 {
local diff_b: display %6.3f r(estimate)
local diff_b = "`diff_b'"
}
if scalar(p) < 0.10 {
local diff_b: display %6.3f r(estimate)
local diff_b = "`diff_b'\sym{*}"
}
if scalar(p) < 0.05 {
local diff_b: display %6.3f r(estimate)
local diff_b = "`diff_b'\sym{**}"
}
if scalar(p) < 0.01 {
local diff_b: display %6.3f r(estimate)
local diff_b = "`diff_b'\sym{***}"
}
estadd local diff_b `diff_b'
estadd local diff_se `diff_se'
}

cap noi lincom _b[1.`i':1.TT] - _b[1.`i':0.TT]

if _rc == 0 {
local diff_se: display %9.3f r(se)
scalar p = 2*(1-normal(abs(r(estimate)/r(se))))
if scalar(p) >= 0.10 {
local diff_b: display %9.3f r(estimate)
local diff_b = "`diff_b'"
}
if scalar(p) < 0.10 {
local diff_b: display %9.3f r(estimate)
local diff_b = "`diff_b'\sym{*}"
}
if scalar(p) < 0.05 {
local diff_b: display %9.3f r(estimate)
local diff_b = "`diff_b'\sym{**}"
}
if scalar(p) < 0.01 {
local diff_b: display %9.3f r(estimate)
local diff_b = "`diff_b'\sym{***}"
}
estadd local diff_b `diff_b'
estadd local diff_se `diff_se'
}

local ++j
}

//esttab was cutting off the table for some reason
esttab using "$d9/Tables/tex/cahw/heteffects.tex", fragment compress coefl(0.TT "Distance learning" 1.TT "Traditional training") b(%10.3f) se(%10.3f) nonumb star(* 0.10 ** 0.05 *** 0.01) replace stats(diff_b diff_se N, layout(@ (@) @) fmt(%9.3f %9.3f %3.0f) labels("\noalign{\smallskip} Difference" " " "\noalign{\smallskip} Observations")) postfoot("\bottomrule \end{tabular}") prehead("\begin{tabular}{lcccccccccc}")