首页 文章

将具有观察次数的列添加到esttab摘要统计表

提问于
浏览
0

我想在SSC的 estout 包中使用 esttab 制作摘要统计表 . 我可以使表格很好,但我想添加一个列,计算每个变量的非缺失观察数 . 也就是说,一些变量可能不完整,我希望读者清楚这一点 .

在下面的例子中,我删除了 price 的前五个观察,所以我希望在那一行中有69个 . 但是我的代码不包括行特定的观察计数,只包括页脚中的观察总数 .

sysuse auto, clear
estpost summarize, detail
replace price = . in 1/5
local screen ///
    cells("N mean sd min p50 max") ///
    nonumber label 
esttab, `screen'

这会产生一个空的 N 列,我希望在69,然后是所有74 .

1 回答

  • 4

    是这个吗:

    clear all
    set more off
    
    *----- exmple data -----
    
    sysuse auto, clear
    keep price mpg rep78 headroom
    
    replace price = . in 1/5
    
    *----- what you want -----
    
    estpost summarize, detail
    
    local screen cells("count mean sd") nonumber label noobs
    
    esttab, `screen'
    

    它只使用 count . esttabestout 的包装器, help 是后者文件的"results from e(myel)",它来自 estpost summarize, detail .

    另一种选择是:

    tabstat _all, statistics(count mean sd) columns(statistics)
    

    还有一个,它只允许显示变量标签:

    fsum _all, stat(n mean sd) uselabel
    

    fsum 来自SSC .

相关问题