6 collect export — Export table from a collection
md option
append specifies that collect export append the table to an existing file.
Remarks and examples stata.com
Remarks are presented under the following headings:
Introduction
Styles for different documents
Creating more extensive documents
Introduction
One goal of creating a customized table may be to present your findings to others. With collect
export, you can export a collection to a variety of file types. For example, after creating a table
from a collection of results and making styling edits to obtain the look you want, you can export a
table from the current collection to an Excel file by typing the following:
. collect export myfile.xlsx
By specifying the .xlsx suffix, we have indicated that we want to export our work to a Microsoft
Excel file. Equivalently, we could have instead specified the document type as follows:
. collect export myfile, as(xlsx)
Either way, we would have exported a table from the current collection to the file myfile.xlsx.
Styles for different documents
The collect suite of commands has many formatting features that can be applied to any collection
of results, regardless of the document you may be exporting your table to. For example, you may
specify the numeric formatting for your results or modify the labels for the dimensions. But there
are also some style specifications that are specific to the type of document you will be exporting to.
For example, you can use collect style html to specify whether adjacent cell borders should be
collapsed in the resulting HTML file. If you will be exporting a table to a .docx or .pdf file, you
can see collect style putdocx and collect style putpdf for some style specifications specific
to those types of documents.
Additionally, you can add a custom table title with collect title and notes with collect
notes. These commands add the title and notes in plain text, but you can specify the appearance
style for the title and notes, respectively, with collect style title and collect style notes.
Certain appearance edits can be rendered only on certain types of documents. For example, you can
specify the font size and color if you will export your table to a Microsoft Excel, an HTML, or a
L
A
T
E
X file.
Creating more extensive documents
With collect export, you can export a customized table to the file format of your choice. If
you are exporting to an HTML, a L
A
T
E
X, a SMCL, a Markdown, or a plain-text file, you can export
multiple tables to a single file with the append option. But you may want to create documents with
more than these customized tables.