Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Table output, how to get percent of row total?

From   Philip Ryan <[email protected]>
To   [email protected]
Subject   Re: st: Table output, how to get percent of row total?
Date   Wed, 08 Oct 2003 09:16:22 +0930


If you have a two-way or three-way table, then, respectively, tab2way and tab3way give whatever combination you wish of frequencies, row, column and cell percents. These can be downloaded from the ssc archive and may, after a bit of cutting and pasting, help achieve your objective.

Opinion piece follows, bail out now if your time is precious.....

As I think Nick Cox has pointed out recently, Stata's tabulation facilities are somewhat scattered and it can be difficult to find exactly what you want among the myriad of official and unofficial commands. My own opinion is that, usually, user-written add-ons are a *very* good thing and add immeasurably to Stata's functionality. But tabulation is such a basic and important tool that a more unified system is needed. Many of us have written front-ends to _tabdisp for particular functions that -table- does not support, but (i) _tabdisp itself is limited and (ii) there is no unified <command/subcommand/option> construct to allow a reasonable choice of presentations of tabular material. (One has in mind the v8 graphics subsystem - complex, admittedly, but now allows a deal of control over the end-product). In Dan's example below, what we have is essentially a collection of Rx2 subtables appended, that is, we have a sex X smoker table then an age group X smoker table and then perhaps other subtables. This is often the format given as "Table 1" of a published paper wherein the baseline characteristics of two or more groups are displayed. Stata can produce the subtables, but (I think) not the end-product, because Stata's tables are all about complete cross-classifications,whereas the display we want here has cross-classifications within a subtable but not between subtables.

In summary I can imagine a tabulation subsystem in Stata that supports a user-defined output - contents and layout - for presentation. Imagination is, of course, cheap.


At 12:58 PM 7/10/2003 -0700, you wrote:


I need to create a table which contains percent of row total and frequency.
I've been looking through table and tabdisp and haven't figured it out.

The table I am looking for is very similar to the following. From
Characteristics of diabetic subjects according smoking status. Figures are
frequencies (percent of row total).

                        Never smoked (968)      Current smoker (296)
Ex-smoker (582) All

Sex     Men             374 (40)                        166 (18)
361 (39)                928
        Women           594 (61)                        130 (13)
221 (23)                971
Age Group (Years)
        < 45            117 (53)                        60 (27)
42 (19)         219
        45-54           126 (57)                        49 (22)
45 (20)         221
        55-64           281 (54)                        78 (15)
151 (29)                520
        65-74           263 (47)                        78 (14)
200 (36)                556
        ? 75            158 (48)                        25 (8)
134 (41)                326
        Not known       23 (40)                 6 (11)                  10
(18)            57

Thanks for your help!

Daniel R. Sabath M.Sc.   Research Consultant
 Dept. of Surgery              325 Ninth Ave
 Harborview Injury Prevention     Box 359960
   and Research Center     Seattle, WA 98104
 [email protected]     (206) 521-1549

*   For searches and help try:
Philip Ryan
Associate Professor,
Department of Public Health
Associate Dean (Information Technology)
Faculty of Health Sciences
University of Adelaide 5005
South Australia
tel 61 8 8303 3570
fax 61 8 8223 4075
CRICOS Provider Number 00123M
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.

*   For searches and help try:

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