← See Stata 19's new features
Highlights
Convert a Word (.docx) document to an EPUB file
Convert a Word (.docx) document to an HTML file
Convert a Word (.docx) document to a Markdown file
Convert a Word (.docx) document to a plain text file
See more reporting features
With the new docx2epub, docx2html, docx2markdown, and docx2txt commands, you can convert Word™ documents (.docx files) to EPUB, HTML, Markdown, and plain text formats. Whether you create a report with Stata results by using putdocx or you have an existing Word document, you can easily convert your document to any of these formats. This feature is a part of StataNow™.
-> Convert a Word (.docx) document to an EPUB file
-> Convert a Word (.docx) document to an HTML file
-> Convert a Word (.docx) document to a Markdown file
-> Convert a Word (.docx) document to a plain text file
We have a Word document, graphs.docx, that contains some Stata graphs; you can download this file to your current working directory by typing
. copy https://www.stata-press.com/data/r19/reporting/graphs.docx .
We convert this file to an EPUB file by typing
. docx2epub graphs.docx
We obtain the EPUB file graphs.epub. Below, we view a snippet of the file with Adobe Digital Editions, but you can open it with any other electronic reading platform that supports .epub files.
Below, we work with the same Word document as above, graphs.docx. We convert this file to an HTML file by typing
. docx2html graphs.docx
We obtain the HTML file graphs.html:
Additionally, you can convert a Word document to a Markdown file. For example, you may want to convert graphs.docx to Markdown and make further modifications before converting it to HTML.
We convert graphs.docx to a Markdown file by typing
. docx2markdown graphs.docx
We obtain the Markdown file graphs.md:
The graphs are extracted and saved as graphs.001.png and graphs.002.png.
Unlike EPUB and HTML files, plain text files cannot contain embedded images. Therefore, we use the putdocx suite of commands to create a file with a table of descriptive statistics and a table of regression results. We use data from the Second National Health and Nutrition Examination Survey (NHANES II) (McDowell et al. 1981) to analyze blood pressure, weight, and body mass index. We run the following commands to create our .docx file:
. webuse nhanes2l, clear
. putdocx begin
. putdocx paragraph
. putdocx text ("We analyze data from the Second National Health and")
. putdocx text (" Nutrition Examination Survey."), linebreak(1)
. quietly: dtable bpsystol weight bmi, by(diabetes)
title("Table 1. Descriptive statistics")
column(by(, halign(right)) total(, halign(right)))
. putdocx collect
. regress bpsystol age weight
. putdocx table bweight = etable, title("Table 2. Linear regression of systolic blood pressure")
. putdocx save bpreport, replace
And now we convert bpreport.docx to a plain text file by typing
. docx2txt bpreport.docx
Here is our plain text file:
McDowell, A., A. Engel, J. T. Massey, and K. Maurer. 1981. “Plan and operation of the Second National Health and Nutrition Examination Survey, 1976–1980.” In Vital and Health Statistics, ser. 1, no. 15. Hyattsville, MD: National Center for Health Statistics.
Learn more about converting Word documents to other formats using the docx2epub, docx2html, docx2markdown, and docx2txt commands in [RPT] docx2epub, [RPT] docx2html, [RPT] docx2markdown, and [RPT] docx2txt in the Stata Reporting Reference Manual.
Learn more about Stata's reporting features.
View all the new features in Stata 19 and, in particular, new in reporting.