Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: -groups- revised on SSC [SPSS-like tables in Stata)


From   n j cox <[email protected]>
To   [email protected]
Subject   st: -groups- revised on SSC [SPSS-like tables in Stata)
Date   Tue, 10 Apr 2007 14:06:53 +0100

At the end of last month, there was a thread
on SPSS-like tables in Stata. The essence
was a desire to be able to see percents
of totals and also percents of valid (non-missing).

As indicated, I added some handles to -groups-
on SSC to do this. To tabulators, -groups- may seem
just a big cheat: it uses -list- to do (possibly very long)
tables. It was originally born out of a desire to see multiway
tables collapsed to a single dimension, but it does
allow a solution here. Thanks to Kit Baum for
putting up the revised files on SSC.

There was some discussion of -groups- in

Speaking Stata: Problems with tables, Part II
Stata Journal 3(4):420--439 (2003)

reviews three user-written commands (tabcount, makematrix,
and groups) as different approaches to tabulation problems

and it is also mentioned in Svend Juul's book on Stata.
See the StataCorp bookstore for more on that.

Consider

. sysuse auto
(1978 Automobile Data)

. groups rep78

  +----------------------------------+
  | rep78   Freq.   Percent     Cum. |
  |----------------------------------|
  |     1       2      2.90     2.90 |
  |     2       8     11.59    14.49 |
  |     3      30     43.48    57.97 |
  |     4      18     26.09    84.06 |
  |     5      11     15.94   100.00 |
  +----------------------------------+

That is the default. It is deliberately
similar to what you get with -tabulate-
and one variable. We can see missings
too:

. groups rep78, missing sep(0)

  +----------------------------------+
  | rep78   Freq.   Percent     Cum. |
  |----------------------------------|
  |     1       2      2.70     2.70 |
  |     2       8     10.81    13.51 |
  |     3      30     40.54    54.05 |
  |     4      18     24.32    78.38 |
  |     5      11     14.86    93.24 |
  |     .       5      6.76   100.00 |
  +----------------------------------+

But the default here with missings is just
like that with -tabulate-.

When you want something different, use
the -show()- option. The little language
of -show()- refers to a display of _f_requencies,
_p_ercents and _v_alid _p_ercents.

. groups rep78, missing sep(0) show(f p vp)

  +-----------------------------------+
  | rep78   Freq.   Percent   % Valid |
  |-----------------------------------|
  |     1       2      2.70      2.90 |
  |     2       8     10.81     11.59 |
  |     3      30     40.54     43.48 |
  |     4      18     24.32     26.09 |
  |     5      11     14.86     15.94 |
  |     .       5      6.76         . |
  +-----------------------------------+

-groups- is built as a wrapper around -list-,
so courtesy of -list-, some other stuff
is easy:

. groups rep78, missing sep(0) show(f p vp) sum

  +-----------------------------------+
  | rep78   Freq.   Percent   % Valid |
  |-----------------------------------|
  |     1       2      2.70      2.90 |
  |     2       8     10.81     11.59 |
  |     3      30     40.54     43.48 |
  |     4      18     24.32     26.09 |
  |     5      11     14.86     15.94 |
  |     .       5      6.76         . |
  |-----------------------------------|
  |   Sum      74    100.00    100.00 |
  +-----------------------------------+

The help for -groups- tells you more.
Incidentally, in a concurrent thread, someone
wanted one d.p. for percents. You can do that
too with -groups-.

By the way, if the next question is Can I
use -groups- to emulate this or that feature
in -tabulate-, -table- or -tabstat-? then the
answer is almost certainly No if it is not obviously
Yes.

-groups- requires Stata 8.

By the way, no one pointed out an earlier
offering on SSC cooked up when a similar question
was asked in 1999. -taba- requires Stata 5 as
a minimum. It is a pretty lousy program, but it
might be a little use to people who have this
problem and who are stuck on Stata <8.

Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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