代码之家  ›  专栏  ›  技术社区  ›  bill999

使用esttab设置表格格式

  •  0
  • bill999  · 技术社区  · 7 年前

    我能够创建我想要的大部分内容:在同一个表中并排创建两个单向表格(报告累计百分比)。这很好,但我需要一些格式方面的帮助。玩具示例:

    sysuse auto, clear
    eststo clear
    eststo a: estpost tabulate rep78 if foreign==0
    eststo b: estpost tabulate rep78 if foreign==1
    esttab, cells("cumpct(fmt(2))") ///
        varlabels("a" "b")      ///
        nonumber nomtitle noobs ///
        collabels("a" "b")
    

    这将产生以下结果:

    --------------------------------------
                            a            a
    --------------------------------------
    1                    4.17             
    2                   20.83             
    3                   77.08        14.29
    4                   95.83        57.14
    5                  100.00       100.00
    Total                                 
    --------------------------------------
    

    我如何才能:

    1. 去掉总行和
    2. 是否使列标签具有不同的名称?我想叫第二列 b a . 我在collabels中使用了不同的内容变体( a b , "a b" , ""a" "b"" ),但似乎没有任何效果。
    1 回复  |  直到 7 年前
        1
  •  2
  •   dimitriy    7 年前

    其中任何一个都可以做到:

    sysuse auto, clear
    eststo clear
    qui eststo a: estpost tabulate rep78 if foreign==0
    qui eststo b: estpost tabulate rep78 if foreign==1
    esttab, cells("cumpct(fmt(2))") ///
        nonumber mtitles("a" "b") nodepvars noobs drop(Total) collabels(none)
    
    eststo clear
    qui eststo a, title("a"): estpost tabulate rep78 if foreign==0
    qui eststo b, title("b"): estpost tabulate rep78 if foreign==1
    esttab, cells("cumpct(fmt(2))") ///
        nonumber mtitles nodepvars noobs drop(Total) collabels(none)
    

    我更喜欢第二种语法,因为我喜欢在估计模型的位置附近命名模型。

    两者都会产生类似于:

    --------------------------------------
                            a            b
    --------------------------------------
    1                    4.17             
    2                   20.83             
    3                   77.08        14.29
    4                   95.83        57.14
    5                  100.00       100.00
    --------------------------------------