Flexible table of summary statistics

The table sub-command of asdocx table calculates and displays tables of statistics. It has the following syntax:

asdocx table rowvar [colvar [supercolvar]] [if] [in] [weight] [, options]

Syntax details

Option contents(clist) specifies the contents of the table’s cells; if not specified, contents(freq) is used by default. contents(freq) produces a table of frequencies. contents(mean mpg) produces a table of the means of the variable mpg. contents(freq mean mpg sd mpg)produces a table of frequencies together with the mean and standard deviation of variable mpg. Up to five statistics may be specified. Elements of clist may be:

      freq                 frequency
      mean varname         mean of varname
      sd varname           standard deviation
      semean varname       standard error of the mean (sd/sqrt(n))
      sebinomial varname   standard error of the mean, binomial distribution (sqrt(p(1-p)/n))
      sepoisson varname    standard error of the mean, Poisson distribution (sqrt(mean))
      sum varname          sum
      rawsum varname       sums ignoring optionally specified weight
      count varname        count of nonmissing observations
      n varname            same as count
      max varname          maximum
      min varname          minimum
      median varname       median
      p1 varname           1st percentile
      p2 varname           2nd percentile
      ...                  3rd-49th percentile
      p50 varname          50th percentile (median)
      ...                  51st-97th percentile
      p98 varname          98th percentile
      p99 varname          99th percentile

row specifies that a row be added to the table reflecting the total across the rows.

column specifies that a column be added to the table reflecting the total across columns.


One-way table – frequencies shown by default

 * Load auto dataset
 sysuse auto , clear
 * One-way table of frequencies
 asdocx table rep78
Tabulation of rep78
Repair Record 1978 Frequency
1 2
2 8
3 30
4 18
5 11
 * One-way table: count non-missing observation of mpg
 asdocx table rep78, contents(n mpg)
Tabulation of rep78
Repair Record 1978 Frequency
1 2
2 8
3 30
4 18
5 11
*One-way table; multiple statistics on mpg requested
 asdocx table rep78, c(n mpg mean mpg sd mpg median mpg)
Tabulation of rep78
Repair Record 1978 count_mpg mean_mpg sd_mpg p50_mpg
1 2 21 4.243 21
2 8 19.125 3.758 18
3 30 19.433 4.141 19
4 18 21.667 4.935 22.5
5 11 27.364 8.732 30


Two-way tables

When you add a second variable to your data, a two-way table will be created. The first variable is displayed in the rows of the table and the second variable is displayed in the columns.

sysuse nlsw88
asdocx table occupation union, replace save(table.html)
Tabulation of occupation union
union worker
Occupation nonunion union
Professional/technical 208 66
Managers/admin 204 19
Sales 468 145
Clerical/unskilled 70 5
Craftsmen 40 10
Operatives 128 83
Transport 19 1
Laborers 171 35
Farmers 1 .
Farm laborers 6 1
Service 7 5
Household workers . 1
Other 87 89

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 $9.99. Its life-time license is available at $49.99. With
the asdocx membership, you get :

  • Life-time license to use
  • All future updates
  • All premium templates / plugins.


Order asdocx