首页 文章

在Stata和esttab中,我如何'align'多个双向制表?

提问于
浏览
0

我正在尝试准备一个表格,该表格将显示多个变量的双向频率表 . 逻辑是每个变量将由相同的二进制指示符制表 .

我想使用estout family命令将输出发送到tex文件 . 但是,每个交叉表都出现在新列中 .

用琐碎的例子

sysuse auto
eststo clear 
eststo: estpost tab headroom foreign, notot
eststo: estpost tab trunk foreign, notot
esttab, c(b) unstack wide collabels(N)

给我一个输出

----------------------------------------------------------------
                      (1)                       (2)             

                 Domestic      Foreign     Domestic      Foreign
                        N            N            N            N
----------------------------------------------------------------
1_missing_5             3            1                          
2                      10            3                          
2_missing_5             4           10                          
3                       7            6                          
3_missing_5            13            2                          
4                      10            0                          
4_missing_5             4            0                          
5                       1            0            0            1
6                                                 0            1
7                                                 3            0
8                                                 2            3
9                                                 3            1
10                                                3            2
11                                                4            4
12                                                1            2
13                                                4            0
14                                                1            3
15                                                2            3
16                                               10            2
17                                                8            0
18                                                1            0
20                                                6            0
21                                                2            0
22                                                1            0
23                                                1            0
----------------------------------------------------------------
N                      74                        74             
----------------------------------------------------------------

有没有办法'对齐'输出,只有两列 - 国内和国外?

1 回答

  • 1

    如果您要输出到tex文件,一种解决方案是使用 esttabappend 选项 . 所以在你的情况下它会是这样的:

    sysuse auto
    eststo clear 
    estpost tab headroom foreign, notot
    eststo tab1
    estpost tab trunk foreign, notot
    eststo tab2
    esttab tab1 using outputfile.tex, c(b) unstack wide collabels(N) replace
    esttab tab2 using outputfile.tex, c(b) unstack wide collabels(N) append
    

    我相信也可能有一个更优雅的解决方案,但这通常很容易实现 . 当 append 时,您可能必须指定一堆选项来删除各种列 Headers (我相信 estout 's default assumes you don' t想要大多数这些 Headers ,因此可能值得研究 estout 而不是 esttab ) .

相关问题