【问题标题】:Formatting Table Using esttab使用 esttab 格式化表格
【发布时间】:2018-02-07 21:37:16
【问题描述】:

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

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""),但似乎没有任何效果。

【问题讨论】:

    标签: format stata tabular


    【解决方案1】:

    其中任何一个都可以解决问题:

    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
    --------------------------------------
    

    【讨论】:

    • eqlabels(, lhs("Repair Rec.")) 的类似物吗?我想在 1,...5 列上方写一些东西。
    • @bill999 试试esttab, cells("cumpct(fmt(2))") mlabels(, lhs("Repair Record")) varwidth(15) collabels(none) nonumber nodepvars noobs drop(Total) noisily
    • 太棒了。谢谢!
    • 这似乎去掉了标题标签,不过(我认为“a”和“b”显示为列标签的原因是 eststo 估计被命名为“a”和“b” )。有没有两全其美的方法?
    • @bill999 我上面错了,所以让我澄清一下。我现在理解它的方式, mlabel() 是一个 estout 选项, mtitle() 是一个 esttab 选项。 esttab 只是 estout 的包装器,语法更有限但更简化,estout 选项在冲突时优先于 esttab 选项。 lhs() 仅适用于 mlabels()、eqlabels() 和 collabels()。但是您可以获得一个修复记录类型的标签,其标题为 eststomlabels(, lhs("Repair Record")) varwidth(15) mtitles,因为在这种情况下它们不会干扰。
    猜你喜欢
    • 1970-01-01
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多