Hello,

I am practicing how to create customised LaTex regression results tables in STATA. However, when I try compiling the LaTex results tables into pdf, Latex gives me an error message that reads "LaTex Error: Environment Table Undefined". Could there be a problem with the STATA code I wrote to create the tables? Here is the STATA code I wrote:

use wagepan, clear

xtset nr year
gen lhour = ln(hour)

levelsof year, loc(yr)
loc nyr: word count `yr'
di "NOTE: This is an `nyr' panel data"

forval i = 1/`nyr' {
loc ny: word `i' of `yr'
quietly {
reg lwage lhour educ if year == `ny'
margins, dyex(educ)
matrix eta = r(b)
matrix s2eta = r(V)
matrix list eta
matrix list s2eta
eststo, add(eta_educ eta[1, 1] s_educ sqrt(s2eta[1, 1]))
reg lwage lhour educ black hisp if year == `ny'
margins, dyex(educ)
matrix eta = r(b)
matrix s2eta = r(V)
matrix list eta
matrix list s2eta
eststo, add(eta_educ eta[1, 1] s_educ sqrt(s2eta[1, 1]))
reg lwage lhour educ c.exper##c.exper black hisp if year == `ny'
margins, dyex(educ exper)
matrix eta = r(b)
matrix s2eta = r(V)
matrix list eta
matrix list s2eta
eststo, add(eta_educ eta[1, 1] s_educ sqrt(s2eta[1, 1]) eta_exper eta[1, 2] s_exper sqrt(s2eta[1, 2]))
}
esttab _all using lwage`ny'.tex, replace ti("Wage Equation Estimation for `ny'") ///
label nomtitle nodepvars not se noobs ar2 booktabs ///
scalar(eta_educ s_educ eta_exper s_exper) ///
addnotes("$\eta$: Semi-elasticity of lwage with respect to educ, exper" ///
"$\eta_{se}$: Standard errors of the semi-elasticity") ///
substitute("_cons" "Constant" "eta_educ" "$\eta_{educ}$" "s_educ" ///
"$\eta_{se}$" "eta_exper" "$\eta_{exper}$" "s_exper" "$\eta_{se}$" ///
"c.exper#c.exper" "Experience$^2$")
}



I NEED HELP PLEASE