[ U ] 21 Creating reports 3
We also want a header and a sentence explaining the results. We could type
. sysuse auto
. putdocx begin
. putdocx paragraph, style(Heading1)
. putdocx text ("Regression results")
. putdocx paragraph
. putdocx text ("Linear regression of mpg on weight, length, and foreign.")
. regress mpg weight length i.foreign
. putdocx table regtable = e(table)
. putdocx save myreg
This creates a Word document named myreg.docx that includes a header with the text “Regression
results” and a standard paragraph with the sentence about the regression. The putdocx table
regtable = e(table) command creates a table in Word using the results returned from the
regress command. The table includes coefficients, standard errors, tests, and confidence intervals
for each of the covariates in the model.
Creating a PDF document works in much the same way. We could type
. sysuse auto
. putpdf begin
. putpdf paragraph, font("",20)
. putpdf text ("Regression results")
. putpdf paragraph
. putpdf text ("Linear regression of mpg on weight, length, and foreign.")
. regress mpg weight length i.foreign
. putpdf table regtable = e(table)
. putpdf save myreg
to create myreg.pdf. We replaced each putdocx command with putpdf, and we specified a font
size of 20 points for the heading instead of using one of Word’s heading styles.
We can, similarly, put results in an Excel file.
. sysuse auto
. putexcel set myreg
. regress mpg weight length i.foreign
. putexcel A3 = etable
This creates myreg.xlsx with the header and table of regression results.
For more information on putdocx, including more extensive examples and suggested workflows, see
[RPT] putdocx intro. For more information on putpdf, see [RPT] putpdf intro. For more information
on putexcel, see [RPT] putexcel.
Stata, Stata Press, and Mata are registered trademarks of StataCorp LLC. Stata and
Stata Press are registered trademarks with the World Intellectual Property Organization
of the United Nations. StataNow and NetCourseNow are trademarks of StataCorp
LLC. Other brand and product names are registered trademarks or trademarks of their
respective companies. Copyright
c
1985–2023 StataCorp LLC, College Station, TX,
USA. All rights reserved.
For suggested citations, see the FAQ on citing Stata documentation.