I am using esttab
+ tabstat
to generate a .tex
file to be opened in LaTeX
. I am close to getting what I want, but there is one issue:
How do I get my standard deviations on the same line after the means? It currently shows up on the line following the mean.
A MWE follows. Note that I am actually creating two tables and appending them on to each other. This just shows up as two separate tables in Stata
, but it works in LaTeX
after I modify the code slightly so as to save to a file and not output to the screen. If there is a way to not append as I do and just do everything at once, that would be super, but I am not aware of one. Note also that I am following the code of this site to go between the two programs.
sysuse auto, replace
*create new categorical variable
quietly gen mod= ""
quietly replace mod="odd" if mod(_n, 2) == 1
quietly replace mod="even" if mod(_n, 2) == 0
*create table - by foreign
quietly eststo clear
quietly estpost tabstat price, by(foreign) statistics(mean sd) listwise nototal
quietly est store A
quietly estpost tabstat mpg, by(foreign) statistics(mean sd) listwise nototal
quietly est store B
esttab A B, main(mean 2) aux(sd 2) label noobs parentheses ///
varlabels(`e(labels)') mtitle("Mean price" "Mean mpg") nostar ///
unstack nonote nonumber collabels(none) refcat(Domestic "Origin", nolabel)
*append to table - by mod
quietly estpost tabstat price, by(mod) statistics(mean sd) listwise nototal
quietly est store A
quietly estpost tabstat mpg, by(mod) statistics(mean sd) listwise nototal
quietly est store B
esttab A B, append main(mean 2) aux(sd 2) label noobs parentheses ///
varlabels(`e(labels)') mtitle("Mean price" "Mean mpg") nostar ///
unstack nonote nonumber collabels(none) refcat(even "Type", nolabel)
Update 1 I solved the problem that I had previously included in this question. That problem had to do with decimal points not showing up in my LaTeX
output. But I was doing something wrong in LaTeX
relating to the implementation of a package. (I simply had to put in the correct number of columns.)
Update 2 I figured out how to get the standard errors in parentheses: remove plain
form the code. I think it is default, but include the parentheses
option. I have updated the code and text to reflect this change.