------------------------------------------------------------------------------- help forstatsmat-------------------------------------------------------------------------------

Produce matrix of descriptive statistics

statsmatvarlist[ifexp] [inrange] [weight] [,stat(list_of_statistics)matrix(matname)by(byvar)missingxposelistwisemagic(#)matlist_options]

Description

statsmatcomputes descriptive statistics forvarlistand places them in any specified matrixmatname. By default, the statistics are minimum, quartiles, maximum, mean and standard deviation: these and/or other statistics returned bysummarize, or easily computable from what it returns, may be specified. The statistics are by default computed for those observations which are non-missing across thevarlist. aweights and fweights may be specified.

Options

stat(list_of_statistics)specifies the statistics desired, from the following list:one of statistic ------ --------- n N count number of non-missing observations sum sum sum_w sum of weight mean mean sd SD standard deviation Var var variance se SE semean standard error of the mean skew skewness skewness kurt kurtosis kurtosis min minimum max maximum p percentiles 1, 5, 10, 25, 50, 75, 90, 95, 99 q percentiles 25, 50, 75 (quartiles) p1 1st percentile p5 5th percentile p10 10th percentile p25 25th percentile p50 med median 50th percentile (median) p75 75th percentile p90 90th percentile p95 95th percentile p99 99th percentile iqr IQR interquartile range (p75 - p25) range range (max - min) zero 0 0 (filler if desired for later editing) extra . . (filler if desired for later editing) (Stata 8 up)

matrix(matname)specifies the name of a matrix in which statistics are to be placed. This option is not required, but saving results in a matrix is the main rationale forstatsmat.

by(byvar)is allowed only with a singlevarnameinvarlist. Results are given separately for the groups of observations defined by distinct values ofbyvar, which is usually a categorical variable.

missingspecifies that results should also be produced for those observations for whichbyvaris missing. The default is to omit them.

matlist_optionsare those allowed withmatrix list. See matrix.

xposespecifies transposing the matrix from the default, with statistics as columns, to statistics as rows.

listwisespecifies that statistics are to be shown for all non-missing values in each variable.

magic(#)specifies a number to be used to denote statistics that are missing. In Stata 7, matrices may not contain missing numbers: instatsmat, as intabstat, the number1e+300is, by default, used instead. In Stata 8 and 9, missing values are shown by default, butmagic()may be used to over-ride that if desired. Other numbers may be specified: for example, if all results shown will be zero or positive,magic(-999)might be convenient. The strong presumption is that at some point downstream users will edit such numbers to denote missing explicitly.

Examples

. use auto

. statsmat price mpg rep78, mat(out1)

. statsmat price mpg rep78, mat(out2) s(mean sd p50)

. statsmat price mpg rep78 if foreign, mat(out3)

. statsmat price mpg rep78, mat(out4) s(mean sd skew kurt) f(%3.2f)

. statsmat price, by(rep78) f(%9.0f) s(n min q max)

. outtable using myout4, mat(out4) replace

AuthorsNicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk

Christopher F Baum, Boston College, USA baum@bc.edu

AcknowledgementsPetia Petrova inspired this program.

Also seeOn-line: summarize, matrix, tabstat, outtable (if installed), univar (if installed)