将表格保存为 csv

Save tabulate as csv

我有兴趣将 tabulate(或类似命令)的 Stata 输出保存到 CSV 文件中。

例如,

sysuse auto, clear
tab headroom rep78

我想将结果(主要是 table 的正文)导出到 CSV 文件中。我该怎么做?

sysuse auto, clear

tabout headroom rep78 using tabtest.csv, style(csv)

tabout 来自 SSC。这意味着要安装 ssc install tabout

或者,如果您只想依赖内置功能,您可以这样做:

sysuse auto, clear
tab rep78 foreign, matcell(x)
svmat x
list x* in 1/10
export delimited x1 x2 using "test", replace

正如在 StataCorp website 上讨论的那样。