带有esttab的频率表
我有兴趣使用Stata输出表命令命令的转置:
sysuse auto, clear
eststo: estpost tab foreign
esttab, cells(b)
这样
--------------------------------------------------
Domestic Foreign Total
--------------------------------------------------
Domestic 52. 22. 74
--------------------------------------------------
我可以做类似的事情的输出:
sysuse auto, clear
est clear
tab foreign, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
drop newp*
esttab, cells("newp_1 newp_2") ///
compress unstack ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
...
------------------------------
Domestic
newp_1 newp_2
------------------------------
sum 52 22
------------------------------
但是当我尝试添加其他变量计数时,我会遇到问题(理想情况下,我想要EST2要垂直附加而不是水平)
sysuse auto, clear
est clear
tab foreign, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
drop newp*
esttab, cells("newp_1 newp_2") ///
compress unstack ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
g example = (mpg >=22)
tab example, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
esttab, cells("newp_1 newp_2") unstack ///
compress ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
...
--------------------------------------------------
Domestic Foreign
newp_1 newp_2 newp_1 newp_2
--------------------------------------------------
sum 52 22 43 31
--------------------------------------------------
我所需的输出是:
---------------------------------
newp_1 newp_2
---------------------------------
sum (foreign) 52 22
sum (price) 43 31
---------------------------------
I'm interested in outputting the transpose of the tabulate command using Stata:
sysuse auto, clear
eststo: estpost tab foreign
esttab, cells(b)
Such that the output would be
--------------------------------------------------
Domestic Foreign Total
--------------------------------------------------
Domestic 52. 22. 74
--------------------------------------------------
I can do something similar with the following:
sysuse auto, clear
est clear
tab foreign, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
drop newp*
esttab, cells("newp_1 newp_2") ///
compress unstack ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
...
------------------------------
Domestic
newp_1 newp_2
------------------------------
sum 52 22
------------------------------
But I run into issues when I try to add counts of other variables (Ideally I'd like est2 to be appended vertically instead of horizontally)
sysuse auto, clear
est clear
tab foreign, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
drop newp*
esttab, cells("newp_1 newp_2") ///
compress unstack ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
g example = (mpg >=22)
tab example, gen(newp_`i')
eststo : estpost tabstat newp_1 newp_2 , stat(sum ) column(variables)
esttab, cells("newp_1 newp_2") unstack ///
compress ///
nonumbers nodepvars noobs ///
mtitles("Domestic" "Foreign")
...
--------------------------------------------------
Domestic Foreign
newp_1 newp_2 newp_1 newp_2
--------------------------------------------------
sum 52 22 43 31
--------------------------------------------------
My desired output is:
---------------------------------
newp_1 newp_2
---------------------------------
sum (foreign) 52 22
sum (price) 43 31
---------------------------------
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下似乎有效:
The following seems to work: