*! version 0.31

Title

sumat Statistical summary table - A wrapper and extension of
summarize

Syntax

sumat varlist [if] [in] [using] ,
statistics(list of statistics)
[options matprint_options]

Required
statistics(string) Specify list of statistics
to get summarized for each variable

Optional
ppct(integer 95) An integer between 0 and 100 specifying the
p value used in confidence and predection intervals

rowby(varname) The name of a categorical variable used to group by
rowwise

colby(varname) The name of a categorical variable used to group by
columnwise

total Add a row and/or a column total.
Only if rowby and/or colby is used

full Get all summary rows even if they are empty.
Option only if rowby or colby is set.
Is set by default if both rowby and colby is set

nolabel Do not use variable labels and value labels as row and
column eq and names

hide(integer) To use pseudo percentiles.
Pseudo percentiles are found by sorting the values and averaging a number of
values around each position. The averages are used to get percentiles
Specify the non negative integer to average around.
Default is zero, i.e. use original values

verbose Show underlying Stata commands used. Sometimes only Mata
code is used

transposed Transpose the returned matrix

Matprint options
style(string) Style for output. One of the values smcl (default),
csv (semicolon separated style),
latex or tex (latex style),
html (html style) and
md (markdown style, experimental)

decimals(string) Matrix of integers specifying numbers of
decimals at cell level. If the matrix is smaller than the data matrix the right
most column is copied to get the same number of columns.
And likewise for the bottom row

title(string) Title/caption for the matrix output

top(string) String containing text prior to table content.
Default is dependent of the value of the style option

undertop(string) String containing text between header and table
content.
Default is dependent of the value of the style option

bottom(string) String containing text after to table content.
Default is dependent of the value of the style option

replace Delete an existing using file before adding table

noeqstrip Do not remove duplicate successive roweq or coleq values

nozero Do not show zeros in output

version 13 and up
toxl(string) A string containing up to 5 values separated
by a comma. The values are:

* path and filename on the excel book to save in. Excel book suffix is set/reset to xls for Stata 13 and to xlsx for Stata 14 and above

* the sheet name to save output in

* (Optional) replace - replace/overwrite the content in the sheet

* (Optional) row, column numbers for the upper right corner of the table in the sheet

* (Optional) columnn widths in parentheses. If more columns than widths the last column width is used for the rest

todocx(string) A string containing one or two values separated
by a comma. The values are:

* path and filename on the excel book to save in.

* (Optional) replace - replace/overwrite the content in the sheet

Description

sumat is a flexible tool to generate survey tables. It differs from
existing tools in that more statistics are possible to report and in that
the summary table is saved for further data handling.

sumat is integrated with matprint such that styling in smcl,
html, latex, csv and markdown is quite easy.

List of statistics

Any non lowercase version of statistics below will also do as an argument.

From summarize

Only for non string variables. In case of a string variable the value
missing (.) is returned.

n count number of observations

sum sum of variable

sum_w sum of the weights

mean mean

sd standard deviation

Var variance

skewness skewness

kurtosis kurtosis

min minimum

max maximum

Derived values

pX Xst percentile for X an integer between 1 and 99. Calculations
are similar to to those from the command centile and not as in
summarize

median 50st percentile

semean Standard error of mean (= standard deviation / sqrt(n))

gmean The geometric mean

gsd Exponentiated standard deviation of the geometric mean

gse Exponentiated standard error of the geometric mean

cv Coefficient of variation (= standard dviation / mean)

range (= max - min)

ci confidence interval (= mean +/- z(alfa) * standard deviation / sqrt(n)).
The value for alfa can be set by option ppct

pi prediction interval (= mean +/- z(alfa) * standard deviation).
The value for alfa can be set by option ppct

iqr interquartile range (= p75 - p25)

iqi interquartile interval (= (p25, p75))

idi interdecentile interval = (p10, p90))

fraction The row fraction of nonmissing values.
Only interesting together with the rowby option

missing number of missing values for the variable.
Works for all types of variables

unique number of unique non missing values for the variable
Works for all types of variables

Examples

`"sysuse auto ,clear"'

Create a summary matrix statistics n, fraction, missing,
unique, mean, sd and a 75% interquartile interval for the variables price and
mpg by foreign (columns) and rep78 (rows)
(see matprint):

`"sumat price mpg, statistics(n fraction missing unique median iqi) rowby(rep78) colby(foreign) decimals(J(1,2,(0,2,0,0,1,1,1)))"'

The output from sumat can easily be exported to excel
using option toxl.

Here the output is saved in sheet "tbl" at the Excel workbook "tbls.xls(x)"
in current directory:

`"sumat price mpg, statistics(median iqi) rowby(rep78) colby(foreign) decimals(1) toxl(tbls, tbl)"'

To see current directory:

cd

To see the Excel workbook (stata 13):

shell tbls.xls

To see the Excel workbook (stata 14 and up):

shell tbls.xlsx

The output from sumat can easily be exported to word
using option todocx.

Here the output is saved in the Word workbook "tbl.docx"
in current directory:

`"sumat price mpg, statistics(median iqi) rowby(rep78) colby(foreign) decimals(1) title(Comment) todocx(tbl, replace)"'

To see the Word document (One can not add several tables to the same Word file):

shell tbl.docx

The option full is to maintain same tablesize when using rowby:

`"sumat foreign if !foreign, statistics(n fraction) rowby(rep78) total full"'

`"sumat foreign if foreign, statistics(n fraction) rowby(rep78) total full"'

Stored results

sumat stores the following in r():

Matrix

r(sumat) The matrix containing all the specified values

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com