Reputation: 21
I have a simple but strange issue cropping up when I use esttab
to export results from Stata into LaTeX.
Once the output is stored in the tex file I import the file into Lyx. However all coefficients are preceded by [em1]
which complies as text in the pdf. Even if I don't import the tex file into Lyx and open it in Texworks, the [em1]
prefix still appears. The only way I can find to remove the [em1]
is manually which is tedious and lacks elegance.
Any ideas why this appears?
Here's the generating code:
svyset w1_wgt
estpost svy: tab reason1, se per
est store w1, title(Model 1)
svyset w2_wgt
estpost svy: tab reason2, se per
est store w2
svyset w3_wgt
estpost svy: tab reason3, se per
est store w3
esttab w1 w2 w3 ///
using "Output/Descriptive Statistics/Absence of Adults.tex" ///
, replace nostar se unstack label tex
Upvotes: 2
Views: 2020
Reputation: 75
this does not appear to be a Stata problem (so you can remove that tag), but a LyX problem. The [1em]
insert (you wrote [em1]
and I'm assuming that's a typo) tells LaTeX how much space to put in between the rows (see my screenshot when I compile the table in Overleaf).
\begin{tabular}{l*{3}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}\\
&\multicolumn{1}{c}{Mean}&\multicolumn{1}{c}{Mean}&\multicolumn{1}{c}{Mean}\\
\hline
p11 & 0.475& 0.876& 0.202\\
& (0.00254)& (0.00194)& (0.00150)\\
[1em]
p21 & 0.525& 0.105& 0.268\\
& (0.00254)& (0.00452)& (0.00600)\\
[1em]
p31 & & 0.0193& 0.276\\
& & (0.00647)& (0.00414)\\
[1em]
p41 & & & 0.254\\
& & & (0.00864)\\
\hline
Observations & 10337& 10337& 10337\\
\hline\hline
\multicolumn{4}{l}{\footnotesize Standard errors in parentheses}\\
\end{tabular}
This table compiles in Overleaf even in a completely bare-bones document:
\documentclass{article}
\begin{document}
\input{test.tex} % This is what I called your table. FWIW I would never put spaces in a file name.
\end{document}
So what you need to figure out next is why LyX is compiling so oddly. If you want more help, please let us know your preamble of loaded packages in LyX and also a screenshot of the table the way it compiles.
Upvotes: 0
Reputation: 793
Try working with outreg instead. Following @RobertoFerrer's example (thanks for giving some working code), you can use outreg
instead of esttab
:
outreg using "C:\...\Absence2.tex", replace nostar se tex
Then just play with the formatting options in outreg. If it has what you need, this might be an easier way to achieve what you want. I have always found esttab
to be better for these tabulations when I need them in MS Excel and outreg
better for TeX. Just IMO, though.
Upvotes: 0
Reputation: 11102
This doesn't answer your question, but you can use filefilter
to get rid of the undesired text:
clear all
set more off
eststo clear
webuse nhanes2f
svyset psuid
svy: tab sex, se per
est store w1
svy: tab race, se per
est store w2
svy: tab region, se per
est store w3
esttab w1 w2 w3 using "D:/Desktop/statatemps/Absence.tex", ///
replace nostar se unstack label tex
filefilter ///
"D:/Desktop/statatemps/Absence.tex" ///
"D:/Desktop/statatemps/Absence2.tex", from("[1em]") to("")
Upvotes: 2