Home  /  Resources & support  /  FAQs  /  Exporting tables from Stata
Note: This FAQ is for users of Stata 16 and older versions.

Stata 17 introduced a redesigned table command and a suite of collect commands for customizing and exporting tables to other formats. For exporting tables in recent versions, please see FAQ: What methods can we use to export a customizable table from Stata to another format?

How do I export tables from Stata?

Title   Exporting tables from Stata
Author Kevin Crow, StataCorp
Shannon Driver, StataCorp
Gabriela Ortiz, StataCorp
Patrick Royston, MRC Clinical Trials Unit, London

To export tables from Stata to other applications you can use one of the official or community-contributed commands available, or you can copy and paste to another application. We discuss some of the commands available for exporting tables, as well as tips for copying and pasting.

  1. Commands for exporting tables from Stata
  2. Official commands

    The putexcel command exports Stata results to an Excel file. You can easily export a matrix or a table of estimation results. putexcel is also great for exporting multiple sets of results because you can format entire rows and columns, and loop over them.

    The putdocx and putpdf suites export Stata results to .docx (Word) files and PDF files. You can easily export the coefficient table from the last estimation command, results from multiple models after estimates table, or the table of margins from the last margins command. You can also create tables from the dataset in memory, matrices, and returned results. These commands are great for exporting customized tables of estimation results as they are equipped with many formatting options.

    The dyndoc and dyntext commands create HTML files, Word documents, and text files with Stata output. You can export a whole regression table, cross-tabulation, or any other estimation results and summary statistics. Output is included in the destination file as it is shown in the Stata Results window.

    Community-contributed commands

    There are several community-contributed commands for exporting tables from Stata, here we mention a few.

    outreg2 is great for exporting regression tables to different file formats, including Word and Excel files. estout creates regression tables from stored estimates, and also works with different file types.

    tabout is great for exporting cross-tabulations and summary tables to a variety of files, including Word and HTML. The tab2docx and tab2xl commands export tabulations to Word and Excel files, respectively.

    You may find that none of the commands listed above fit your needs, in which case you can use Stata's search command to search the internet for other community-contributed commands and install the one that suits your purpose. While connected to the internet, type search outreg2, all, for example, in your Stata Command window to find the command outreg2. The search command will display a link you can click to install the outreg2 command.

  3. Copying and pasting tables
  4. Another way of exporting tables from Stata to other applications is by highlighting the table in the Stata Results window, going to the Edit menu, and selecting Copy, Copy Table, or Copy Table as HTML. After you have copied the table, you can paste the table into another program.

    You should use the Copy Table option if you are pasting the table into a spreadsheet application, such as Excel. The Copy Table option copies the table as a tab-delimited file so that each number, when pasted, will transfer into a separate cell.

    You can use the Copy, Copy Table, or Copy Table as HTML options if you are pasting the table into a word-processing application, such as Word. If you are using Copy, once you have pasted the table into the word processor, you will probably need to change the font to a fixed-width font (such as Courier New) so that your table lines up correctly. You might also need to change the font of the table to a smaller size.

    Windows users might be interested in the following excerpt from Driver and Royston (2004):

    Begin quotation from Driver and Royston (2004):

    Suppose that you want to save a table constructed using tabstat in a form that makes it easy to convert into a table in MS Word. Stata has a Copy Table feature that you might find useful. Make sure at the outset that you have set suitable options by clicking Edit in the menu bar and then Table Copy Options. Here removing all the vertical bars is advisable, so make sure Remove all is selected, and click OK. Now highlight the table in the Results window, and click Edit and then Copy Table.

    In MS Word, click Edit and then Paste. Highlight the pasted text and click Table and then Convert and Text to Table. Specify Tabs under the Separate text at if it is not already selected. Click OK to create your table.

    End quotation from Driver and Royston (2004)

  5. Writing a command
  6. A third option for exporting tables from Stata is to write your own command to export a table. If you have a lot of tables to export or you need to export a table while Stata is running in batch mode, writing your own command using Stata's ado-language is the most logical solution.


Driver, S., and P. Royston. 2004.
Stata tip 7: Copying and pasting under Windows. Stata Journal 4: 220.