如何在 svy 之后将 table 输出到 LaTeX:两种方式制表
How to output table to LaTeX after svy: tabulate two way
我试图在使用 svy: tab
后输出 table 到 TeX。考虑这个例子:
use https://www.stata-press.com/data/r16/nhanes2f, clear
svyset psuid [pweight=finalwgt], strata(stratid)
eststo sexrace: svy, subpop(rural): tab sex race, row percent format(%9.3g)
esttab sexrace
但这只给我单元格百分比,而不是行百分比。我 运行 ereturn list
似乎根本没有存储这些行百分比;它们仅用于显示结果。
我也试过:
tabout sex race using table2.tex, replace c(row) layout(row) svy stats(chi2) percent
但我得到不同的数字。
注意:如果你还没有安装estout
和tabout
,为了运行上面的命令你需要这样安装这两个包:
ssc install estout
ssc install tabout
以下对我有用:
use https://www.stata-press.com/data/r16/nhanes2f, clear
svyset psuid [pweight=finalwgt], strata(stratid)
svy, subpop(rural): tab sex race, row percent format(%9.3g)
--------------------------------------
1=male, | 1=white, 2=black, 3=other
2=female | White Black Other Total
----------+---------------------------
Male | 94.3 3.87 1.79 100
Female | 96.1 2.87 .993 100
|
Total | 95.2 3.37 1.4 100
--------------------------------------
Key: row percentage
Pearson:
Uncorrected chi2(2) = 19.0178
Design-based F(1.81, 52.45) = 2.1654 P = 0.1294
tabout sex race if rural == 1 using table2.tex, style(tex) ///
replace c(row) svy stats(chi2) f(3) mult(100)
1=white, 2=black, 3=other
White Black Other Total
% % % %
1=male, 2=female
Male 94.346 3.865 1.789 100.000
Female 96.137 2.870 0.993 100.000
Total 95.231 3.373 1.396 100.000
Pearson: Uncorrected chi2(2)= 19.018
Design-based F(1.81, 52.45)= 2.165
P-value= 0.129
我试图在使用 svy: tab
后输出 table 到 TeX。考虑这个例子:
use https://www.stata-press.com/data/r16/nhanes2f, clear
svyset psuid [pweight=finalwgt], strata(stratid)
eststo sexrace: svy, subpop(rural): tab sex race, row percent format(%9.3g)
esttab sexrace
但这只给我单元格百分比,而不是行百分比。我 运行 ereturn list
似乎根本没有存储这些行百分比;它们仅用于显示结果。
我也试过:
tabout sex race using table2.tex, replace c(row) layout(row) svy stats(chi2) percent
但我得到不同的数字。
注意:如果你还没有安装estout
和tabout
,为了运行上面的命令你需要这样安装这两个包:
ssc install estout
ssc install tabout
以下对我有用:
use https://www.stata-press.com/data/r16/nhanes2f, clear
svyset psuid [pweight=finalwgt], strata(stratid)
svy, subpop(rural): tab sex race, row percent format(%9.3g)
--------------------------------------
1=male, | 1=white, 2=black, 3=other
2=female | White Black Other Total
----------+---------------------------
Male | 94.3 3.87 1.79 100
Female | 96.1 2.87 .993 100
|
Total | 95.2 3.37 1.4 100
--------------------------------------
Key: row percentage
Pearson:
Uncorrected chi2(2) = 19.0178
Design-based F(1.81, 52.45) = 2.1654 P = 0.1294
tabout sex race if rural == 1 using table2.tex, style(tex) ///
replace c(row) svy stats(chi2) f(3) mult(100)
1=white, 2=black, 3=other
White Black Other Total
% % % %
1=male, 2=female
Male 94.346 3.865 1.789 100.000
Female 96.137 2.870 0.993 100.000
Total 95.231 3.373 1.396 100.000
Pearson: Uncorrected chi2(2)= 19.018
Design-based F(1.81, 52.45)= 2.165
P-value= 0.129