[Stata] How to export Stata results tables to a Word file with 'putdocx'

This post covers how to export Stata results tables to a Word file with using putdocx command.


    1. Preparation

    For a demonstration, we will use 'auto' dataset that Stata provides .

    sysuse auto.dta
    

    2. Demonstration 1 - One table

    The following set of syntax will make a Word file.

    putdocx begin
    
    *syntax for analysis
    reg price mpg weight length i.foreign
    
    putdocx table Table1=etable
    
    *Designating the file name
    putdocx save "file_1"
    

    The file directory where the Word file is saved will be shown among the results section.

    In my case, the file is saved in the 'Document' folder.




    3. Demonstration 2 - Multiple tables

    We can also put multiple tables in a single Word file.

    For example, we will export three tables.

    putdocx begin
    
    *analysis syntax 1
    reg price mpg weight length i.foreign
    
    putdocx table Table1=etable
    
    *analysis syntax 2
    reg price mpg weight length 
    
    putdocx table Table1=etable
    
    *analysis syntax 3
    reg price weight length
    
    putdocx table Table1=etable
    
    *Designating the file name
    putdocx save "file_2"
    



    Another option is to reapeat the set of syntax in Demonstration 1 with changing the analysis syntax and the file name, but this will make multiple Word files.


    For a more detailed guideline, refer to the link below.

    https://www.stata.com/manuals/rptputdocxintro.pdf

    Post a Comment

    0 Comments