Export tabdisp table from Stata to Excel, Word
The command tabdisp is used to display data in a table format. It can accept up to three variables after the command name, with the first variable determining the rows of the table, the second variable determining the columns, and the third variable determining the super-columns. One required option for tabdisp is the cellvar() option. This option specifies the numeric or string variables containing the values that should be displayed in the table’s cells. A maximum of five variable names can be specified for this option.
* Load example data use http://www.stata-press.com/data/r13/tabdxmpl3, clear * add asdocx as a prefix to tabdisp asdocx tabdisp agecat sex party, c(reaction) replace
Party Affiliation and Sex | ||||||||
---|---|---|---|---|---|---|---|---|
Democrat | Republican | |||||||
Age category | Female | Male | Female | Male | ||||
Old | Favor | Favor | Indifferent | Strongly Favor | ||||
Young | Strongly Favor | Indifferent | Disfavor | Disfavor | ||||
Notes: |
Export group statistics with tabdisp
tabidsp is quite useful when you want to present summary statistics at the intersection of row and column variables. To show an example, the following code loads the nlsw88 dataset using the sysuse command. Then, the collapse command computes the mean of two variables, ttl_exp
(total experience) and tenure
, by the intersection of two categorical variables, industry and race. The resultant summary statistics table is then exported to a .docx file using the asdocx command. Specifically, the tabdisp option displays the table of mean values of ttl_exp
and tenure
for each combination of industry and race. The replace option removes any existing files if a .docx file with the specified name already exists.
* Load nlsw88 data from the Stata installed datasets
sysuse nlsw88
* Collapse the data to find mean of ttl_exp and tenure by industry and race
collapse (mean) ttl_exp tenure , by(industry race )
* Export the summary statistics using asdocx tabdisp
asdocx tabdisp industry race , c(ttl_exp tenure ) replace
See also
- tabmany – Table of multiple coded answers
- mrtab – One- and two-way tables of multiple responses
- tabcount – tabulates frequencies for up to 7 variables
- missings – Various utilities for managing missing values
- tabulate, tab1, tab2
Order asdocx
Yearly license of asdocx is available at £14.99. Its life-time license is available at £59.99. With the asdocx membership, you get :
- Life-time license to use
- All future updates
- All premium templates / plugins.