|Title||Copying tables from Stata|
Kevin Crow, StataCorp
Shannon Driver, StataCorp
Patrick Royston, MRC Clinical Trials Unit, London
|Date||December 2004; modified April 2005|
The easiest way to copy a table from Stata to another application is to highlight the table in the Stata Results window, and go to the Edit menu, and select 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)
Another way to transfer your table to another application is to export the table as a text file or as a dataset using a user-written Stata command. There are several user-written commands for exporting tables from Stata, such as outreg2.
Use the search command to search the Internet for user-written commands. 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.
The last option you have for exporting tables in 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.