[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: revised -tabstatmat- on SSC

From   "Austin Nichols" <>
Subject   st: revised -tabstatmat- on SSC
Date   Wed, 26 Nov 2008 12:05:14 -0500

Thanks to Kit Baum,
a new version of -tabstatmat- is available from SSC. -tabstatmat-
collects in one matrix a variety of useful summary statistics produced
by -tabstat- for numeric variables, possibly by values of another
variable. Without the by() option, -tabstat- is a useful alternative
to -summarize- because it allows you to specify the list of statistics
to be displayed; with the by() option, -tabstat- resembles -tab,
sum()- in that it reports statistics for a varlist for each of the
different values of another variable.

This version of -tabstatmat- should not issue conformability errors
and reworks the labels on the resultant matrix so they should better
match the output from -tabstat-

It is possible that the changes may break certain uses of the older
version of the command; if so, I do not know which uses those might be
(my certification script runs fine on the new version, but I don't
test every possible use).  You may want to back up the old version
under a different name before updating if you use -tabstatmat- for
nonstandard applications.

If you want to compare the old version of -tabstatmat- to the new one,
issue the following commands in order (or paste the whole block to the
command window) to back up the old version in a new file, and then try
out both versions:

loc f `"`c(sysdir_plus)'t/"'
filefilter `"`f'tabstatmat.ado"' `"`f'tsm0.ado"', from("tabstatmat") to("tsm0")
ssc inst tabstatmat, replace
sysuse auto, clear
qui tabstat price mpg, by(rep78) s(mean sd min max) save mi
tsm0 A
tabstatmat B

To get results into Excel on a Windows system, you might want to
download -xml_tab- from SSC and then try:

qui tabstat price mpg, by(foreign) s(mean sd min max) save
tabstatmat C
xml_tab C, save(temp.xls)
erase temp.xls

To get results into LaTeX, you might want to download -outtable- from
SSC; see also

Note also that -estout- on SSC can produce formatted RTF files
suitable for opening directly in MS Word containing tables of summary
statistics; see e.g. -help estadd- and
but preventing casewise deletion of missing values is difficult, I believe:
i.e. without a lot of extra work, the summary stats will be for obs
with all vars nonmissing.

A loop (using -foreach- or equivalent) over -display- or -file- or
both commands tends to be the most versatile approach to these kinds
of problems, since you are limited only by your own imagination; see

On Tue, Nov 25, 2008 at 1:31 AM, User Stata <> wrote:
> Dear Users,
>   my students is using Stata 10.0 but find that tabstatmat cannot
> work here properly
> Chuntao Li
*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index