我正在使用 esttab
tabstat
生成 .tex
文件,以便在 LaTeX
中打开 . 我接近得到我想要的东西,但有一个问题:
如何在平均值之后在同一条线上获得标准偏差?它目前显示在平均线之后 .
MWE如下 . 请注意,我实际上创建了两个表并将它们相互附加 . 这只是在 Stata
中显示为两个单独的表,但在我稍微修改代码以便保存到文件而不输出到屏幕后,它在 LaTeX
中有效 . 如果有一种方法可以不像我那样追加,只是一次做所有事情,那将是超级的,但我不知道一个 . 另请注意,我遵循this site的代码来介于两个程序之间 .
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 我解决了我之前在此问题中包含的问题 . 这个问题与我的 LaTeX
输出中没有显示的小数点有关 . 但是我在 LaTeX
中做了一些与实施包有关的错误 . (我只需要输入正确数量的列 . )
Update 2 我想出了如何在括号中得到标准错误:从代码中删除 plain
. 我认为它是默认的,但包括 parentheses
选项 . 我已更新代码和文本以反映此更改 .
1 回答
只需在
esttab
代码中包含onecell
即可 . 见documentation .