Adds means, min, max, etc. to the data set ------------------------------------------ ^stats^ varlist [^if^ exp] [^in^ range]^ [ , [ type [type] .. ] [ ^by(^varlist2^) ] [ ^nodescr^ ] [^ collapse^ [^nowarning^] [^keep(^varlist3^)^] ] ] where type is one of: ^count^ number of non-missing observations (prefix: CT) ^mean^ mean (MN) ^median^ median (MD) ^var^ variance (VR) ^sdev^ standard deviation (SD) ^min^ minimum (MI) ^max^ maximum (MA) ^range^ range (max-min) (RG) ^sum^ sum of observations (SM) ^lf^ 25th percentile (LF) ^uf^ 75th percentile (UF) ^df^ 75th-25th percentile (interquartile range) (DF) ^perc(^number^)^ percentile indicated by (0-100) (PT) ^stats^ , continued ----------------- Adds variables to the data set in memory containing statistics as specified by one or more 's. The default type is the mean. If ^by(^varlist2^)^ is specified , the statistics will be calculated for each set of values of . The description of the output data set can be suppressed by ^nodescr^. The new variables have the same names as the old ones with a two-letter prefix indicating the type of the statistic. If the option ^collapse^ is used, the dataset will be collapsed to one obser- vation for each set of values of . Only the added statistics and the variables in and will remain. ^nowarning^ suppresses a warning against destroying the data set. Examples: . ^stats age income^ adds the variables MNage and MNincome to the dataset , containing the means (default) of age and income. . ^stats age income , by(region) mean^ adds the variables MNage and MNincome to the dataset , containing the means of age and income by region. . ^stats age income, by(region) mean perc(33) collapse^ produces a new dataset of region , MNage , PTage , MNincome and PTincome containing mean and 33th percentile per region , one observation per region. Since converting the data results in the loss of the data in memory, ^stats^ warns you and asks if you really want to continue. ^nowarning^ suppresses the warning and the subsequent question and answer.