10 table — Table of frequencies, summaries, and command results
table can accommodate a variety of layouts. You can define the rows, columns, and even separate
tables by levels of categorical variables, statistics, or Stata commands.
If your goal is simply to create a table of estimation results or descriptive statistics, you can use the
etable and dtable commands, respectively. These commands allow you to create these tables and
export them to a variety of file types in a single step. However, unlike table, these commands create
tables with a predefined layout. Therefore, if you want control over the layout or you wish to include
a combination of summary statistics, estimation results, and results from other Stata commands, you
should use the table command.
In the following entries, we provide simplified syntax, examples, and discussion for specialized
types of tables that can be created using table. If you are interested in creating one of these types
of tables, we suggest reading the corresponding entry.
[R] table oneway One-way tabulation
[R] table twoway Two-way tabulation
[R] table multiway Multiway tables
[R] table summary Table of summary statistics
[R] table hypothesis tests Table of hypothesis tests
[R] table regression Table of regression results
All the concepts demonstrated in the entries above can be combined to create tables including
combinations of tabulations, summary statistics, hypothesis tests, and regression results.
In this entry, we provide additional information on specifying the table layout and which portions
of the layout table will automate for you. In addition, we provide resources for customizing the
table and exporting the results to your preferred format.
Specifying the table layout
A table’s layout is determined by our row, column, and table dimension specifications. For example,
we specify variable names to define the rows and place statistics in the columns, or vice versa. Because
we can include so many different statistics, we can specify keywords that we use to identify the
results we have collected from commands and the statistics that table has calculated.
The syntax for specifying the table layout is
table (
rowspec
) (
colspec
) (
tabspec
)
We refer to rowspec, colspec, and tabspec collectively as the “layout”. For some tables, keywords
are required in the layout to uniquely identify the values that we want to include in our table. If you
omit a necessary keyword from the layout, table will fill one in for you.
The rules determining whether a keyword is necessary to uniquely identify values in the table are
as follows:
1. If more than one statistic is specified, then result is needed in the layout.
2. If more than one variable is specified in option statistic() and option command() is not
specified, then var is needed in the layout.
3. If more than one across() specification is used for ratio statistics, then across is needed
in the layout.
4. If option command() is specified, then colname is needed in the layout. If, in addition,
more than one variable is specified in option statistic(), then colname is needed instead
of var, which was required in 2.