Stata新命令:Export tabulation results to Excel


Stata连享会 精彩推文1 || 精彩推文2


Stata Blog 更新了一条新的博客,介绍了一个将 Stata 表格导入 Excel 或 Word 快捷命令,效果不错!

Source: Export tabulation results to Excel—Update


Home > Data Management > Export tabulation results to Excel—Update

Export tabulation results to Excel—Update

7 June 2018 Kevin Crow, Senior Software Developer || Go to comments

Tweet

It’s summer time, which means we have interns working at StataCorp again. Our newest intern, Chris Hassell, was tasked with updating my community-contributed command tab2xl with most of the suggestions that blog readers left in the comments. Chris updated tab2xl and wrote tab2docx, which writes a tabulation table to a Word file using the putdocx command.

To install or update your tab2xl command, type

net install http://www.stata.com/users/kcrow/tab2xl, replace

To install the new tab2docx command, type

net install http://www.stata.com/users/kcrow/tab2docx

tab2xl now allows weights, if, in, formatting of the cells, and two-way tabulations. Once installed, you can type

. sysuse auto, clear
(1978 Automobile Data)
. tab2xl rep78 foreign in 1/50 [fweight=mpg] using testfile, col(1) row(1)
file testfile.xlsx saved

to produce

Stata新命令:Export tabulation results to Excel_第1张图片

To write the table to a Word document, you must first open a .docx file using the command putdocx begin, type your tab2docx command to append the table to your file, and then save the document using putdocx save filename. For example, typing

. sysuse auto, clear
(1978 Automobile Data)
. putdocx begin
. tab2docx rep78 in 1/50 [fweight=mpg]
. putdocx save testfile.docx

will produce

Stata新命令:Export tabulation results to Excel_第2张图片

Chris did an excellent job updating tab2xl and coding tab2docx, making it easier for you to create tables for inclusion in a Word file.

Stata连享会 精彩推文1 || 精彩推文2

关于我们

  • Stata 连享会(公众号:StataChina)】由中山大学连玉君老师团队创办,旨在定期与大家分享 Stata 应用的各种经验和技巧。
  • 公众号推文同步发布于 【-Stata连享会】 和 【知乎-连玉君Stata专栏】。可以在知乎中搜索关键词StataStata连享会后关注我们。
  • 点击推文底部【阅读原文】可以查看推文中的链接并下载相关资料。

Stata连享会 精彩推文1 || 精彩推文2

联系我们

  • 欢迎赐稿: 欢迎将您的文章或笔记投稿至Stata连享会(公众号: StataChina),我们会保留您的署名;录用稿件达五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
  • 意见和资料: 欢迎您的宝贵意见,您也可以来信索取推文中提及的程序和数据。
  • 招募英才: 欢迎加入我们的团队,一起学习 Stata。合作编辑或撰写稿件五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
  • 联系邮件: [email protected]

往期精彩推文

Stata连享会推文列表

Stata连享会 精彩推文1 || 精彩推文2


Stata新命令:Export tabulation results to Excel_第3张图片
欢迎加入Stata连享会(公众号: StataChina)

你可能感兴趣的:(Stata新命令:Export tabulation results to Excel)