-------------------------------------------------------------------------------help for stat2data-------------------------------------------------------------------------------

Title

stat2data ---Generates a Dataset of Descriptive Statistics Calculated for a List of Variables+--------------------+ ----+ Table of Contents +-----------------------------------------------

Syntax General description of

stat2dataDescription of the options Examples Author information

stat2datavarlist[if] [in] [weight],saving(filename[,suboption])[other_options]

optionsDescription ------------------------------------------------------------------------- Mainby(varname)request statistics by variablestatistics(statname[...])create dataset for specified statisticsOptions

generate(newvarlist)generatenewvar_1, ...,newvar_kfor each requested statisticcasewiseperform casewise deletion of observationsmissingreport statistics for missing values ofby()variableformat[(%fmt)] display format for statistics; default format is%9.0gsaving(filename[,suboption])save dataset of statistics to filefilename; this option is required wheresuboptionmust equalreplaceto overwrite filename

+-------------+ ----+ Description +------------------------------------------------------

stat2data, a wrapper for and ostensibly an extension of the Stata's official tabstat command, generates a dataset of descriptive statistics calculated for a list of variables.stat2data's output is different from that of collapsing a dataset using the collapse command. In the dataset generated bystat2data, the statistics are in columns and the variables for which the statistics were calculated are in rows. In other words, statistics become variables and variables become observations. If theby()option is specified, the dataset will contain observations for each variable and for each value of the by variable including missing if themissingoption is specified.

+---------+ ----+ Options +----------------------------------------------------------

by(varname)specifies that the dataset contain statistics for each unique value ofvarname, which may be numeric or string.

statistics(statname[...])specifies the statistics for which the dataset needs to be generated. If this option is not specified,statistics(mean)is assumed.While tabstat allows both

medianandqto be requested,stat2datadoes not sincemedianwill be reported whenqis specified.

generate(newvarlist)indicates the names of the variables to hold the statistics. Specify a variable name for each statistic unlessqis listed among the statistics to request p25, p50, and p75.If

generate()is not specified,stat2datawill form variable names by prefixing the name for each specified statistic with ans. Ifqis listed among the statistics to be calculated andgenerate()is specified, you need two more variable names, in addition to those specified for each statistic listed.

formatandformat(%fmt)specify how the statistics are to be formatted when the dataset is created. The default is to use a%9.0gformat.

casewisesee tabstat.

missingspecifies that statistics for the missing values of theby()variable, ifby()is specified, be included in the dataset. The default is to exclude from the dataset the statistics for the missing of theby()==missinggroup.

stat2data's optionsby(),statistics(),format,casewise, andmissingare apparently equivalent to those of tabstat.

saving(filename[,suboption])specifies that the dataset to be generated for the calculated statistics be saved to the Stata data filefilename. The dataset will be placed in the current directory. Specifying the suboptionreplacewill overwrite an existingfilename.If your

filename(including its path) contains embedded spaces, remember to enclose it in double quotes.

+----------+ ----+ Examples +---------------------------------------------------------

. sysuse auto, clear

. stat2data price mpg trunk weight length turn, saving(statdata) by(rep78) stat(mean sd k sk q) missing

. preserve

. use statdata, clear

. list

. restore

P. Wilner Jeanty, the Kinder Institute for Urban Research/Hobby Center for the > Study of Texas, Rice University, Houston, Texas. pwjeanty@rice.edu

See alsoOnline: tabstat