Tag Archives: Tabulation in Stata

  • 4

Exporting tabs and cross-tabs to MS Word from Stata with asdoc

Category:Blog Tags : 

For installation and other uses of asdoc, please see this short blog post.

Tabulation and Cross-tabs with asdoc

Exporting tables created by Stata commands such as tab, tabulate1, tabulate12, table, tabsum, tab1, tab2, and others to MS word is super easy with asdoc.  As with other commands, we need to just add asdoc as a prefix to the tabulation commands that includes tabulate, tabulate1 tabulate2, tab1, tab2, etc. Since frequency tables in Stata can assume different structures, asdoc writes these tables from log files.

 

One-way table

Example: One-way table

sysuse auto, clear 
asdoc tabulate rep78, replace

 

Please note that replace is asdoc option to replace the existing file. If we were to write to the existing file, we would then use option append, instead of replace.

 

Two-way table of frequencies

 

webuse citytemp2, clear

asdoc tabulate region agecat, replace

 

Example: Include row percentages

 

asdoc tabulate region agecat , nokey row replace

Note nokey suppresses the display of a key above two-way tables.

 

Example: Include column percentages

asdoc tabulate region agecat , nokey column replace

 
Example: Include row percentages, suppress frequency counts

asdoc tabulate region agecat, nokey row nofreq replace

 

One- and two-way tables of summary statistics

Example: One-way tabulation with summary statistics

 

sysuse auto, clear
asdoc tabulate rep78, summarize(mpg) replace

 

Example: Two variables tabulation with summary statistics

generate wgtcat = autocode(weight, 4, 1760, 4840)

asdoc tabulate wgtcat foreign, summarize(mpg) replace

 

Example: Suppress frequencies

asdoc tabulate wgtcat foreign, summarize(mpg) nofreq replace

 

Multiple-way tabulation (tab1)

tab1 produces a one-way tabulation for each variable specified in varlist.

Example: Multiple-way tabulation

sysuse nlsw88, clear
asdoc tab1 race married grade, replace

 

Two-way for all possible combinations (tab2)

Example: Two variables tabulation with summary statistics

asdoc tab2 race south, replace