Examples from the help file

The examples in help desctable, run in full

The examples at the end of help desctable, run in order. Each call writes an Excel file named by filename(); the tables for the first, second, and fifth examples are shown on the overview page.

The default table: means (proportions for the binary and nominal variables) and standard deviations.

sysuse nlsw88, clear
(NLSW, 1988 extract)
desctable wage age i.race i.union i.collgrad tenure i.occupation hours, filename("descriptivesEX1"
)
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
..

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable

stats() selects the statistics and the order of their columns.

desctable wage age i.race i.union i.collgrad tenure i.occupation hours, filename("descriptivesEX2"
) stats(mean freq sd min max iqr median)
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
.......

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable

font() and fontsize() change the typeface and size of everything in the table (the defaults are Times New Roman, 11 point).

desctable wage age i.race i.union i.collgrad tenure i.occupation hours, filename("descriptivesEX3"
) font("Helvetica") fontsize(13)
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
..

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable

decimals() sets the number of decimal places (the default is 2).

desctable wage age i.race i.union i.collgrad tenure i.occupation hours, filename("descriptivesEX4"
) decimals(3)
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
..

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable

group() reports the statistics separately for each category of a nominal grouping variable, side by side.

desctable wage age i.union i.collgrad tenure i.occupation hours, filename("descriptivesEX5") group
(race)
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
......

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable

notes() adds footnotes beneath the table; a long note can be split over several quoted strings on separate lines of the command.

desctable wage age i.race i.union i.collgrad tenure i.occupation hours, ///
    filename("descriptivesEX6") ///
    notes("This is the first footnote." ///
          "This is how to split long footnotes" ///
          "onto multiple lines of the code.")
Sample size reported at the top of the table is # of total observations in the data.


The sample size varies across variables in the table due to missing data.
388 observations have some missing data on variables in the table.
 - Variables with missing data are:
    union tenure occupation hours 


Use the stat(n) option to show the # of non-missing obs for each variable.
Use the listwise option to exclude observations with any missing data.
..

Descriptive statistics table has been saved in the folder:
C:\Users\trent\stata\desctable
Back to top