Differences between revisions 1 and 2
Revision 1 as of 2023-06-07 20:40:30
Size: 1630
Comment:
Revision 2 as of 2025-10-24 17:31:01
Size: 1744
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The '''`putdocx`''' command is used for generating Word Documents. '''`-putdocx-`''' manipulates Word documents.
Line 29: Line 29:
To insert a table, first it must be stored in a matrix. To insert a table, first it must be stored in a [[Stata/Matrices|matrix]].
Line 67: Line 67:
External graphs can be inserted. [[Stata/Graph|Graphs]] can be inserted.
Line 100: Line 100:
----



== See also ==

[[https://www.stata.com/manuals15/pputdocx.pdf|Stata manual for -putdocx-]]

Stata PutDocx

-putdocx- manipulates Word documents.


Usage

putdocx begin, footer(foot1) header(head1)

putdocx paragraph, style(Title)
putdocx text ("Document Title")

putdocx paragraph, style(Heading1)
putdocx text ("Section Heading")

putdocx save foo.docx

Tables

To insert a table, first it must be stored in a matrix.

tab foo bar, matcell(foobar)

Then try:

putdocx table foobar = etable

The table can then be accessed by by NAME(ROW,COL).

putdocx table foobar(1,.), bold
putdocx table foobar(.,1), halign(left)
putdocx table foobar(3,.), drop
putdocx table foobar(1,1) = ("FOOBAR")

Headers and Footers

Try:

putdocx paragraph, tofooter(Foot1)
putdocx text("Page Number ")


External Content

Graphs can be inserted.

graph export foo.png
putdocx image foo.png, height(1) width(1)

Note that dimensions are measured in inches.

External text can also be inserted.

putdocx textfile foo.txt

The content of the external file is inserted from the cursor position. Use the stopat(pattern) option to halt insertion at some pattern match; the cursor will remain at that point.


Dynamic Tags

Dynamic tags are used to insert computed values.

putdocx textblock begin
Substitution: <<dd_docx_display: `total'>>.
putdocx textblock end

These can also be appended using putdocx textblock append.


See also

Stata manual for -putdocx-


CategoryRicottone

Stata/PutDocx (last edited 2025-10-24 17:31:01 by DominicRicottone)