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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Formatting Columns in Tabstat |

Date |
Mon, 17 Jun 2002 08:47:41 +0100 |

Michael Oakes > > > > Tabstat is useful module, permitting one to select statistics to be > > displayed. For example: > > > > . tabstat q7a q7b q7c, stats(n mean median) column(s) > > > > variable | N mean p50 > > -------------+------------------------------ > > q7a | 254 6.185039 7 > > q7b | 255 5.011765 5 > > q7c | 254 5.61811 6 > > -------------------------------------------- > > > > I like means to be displayed to only 2 decimal places. I can format my > > variables and ask for formatted output, such as > > > > . format q7a - q7c %9.2f > > > > . tabstat q7a q7b q7c , stats(n mean median) column(s) f > > > > variable | N mean p50 > > -------------+------------------------------ > > q7a | 254.00 6.19 7.00 > > q7b | 255.00 5.01 5.00 > > q7c | 254.00 5.62 6.00 > > -------------------------------------------- > > > > But then all the table elements are formatted 9.2f! > > > > Is there an easy way to just get means (or any given) column formatted > > uniquely? myself > The short answer, I believe, is No, not within -tabstat-. > > I had the same issue recently and issued two > -tabstat- commands, one with the format I > wanted for means (and in my case SDs as well) > and one with default format. I then joined the > tables in my favourite text editor. Not ideal, > but seemingly the best that could be done, > apart from writing my own program, which seemed > more work for my problem. > > Not your problem, but somewhere in cyberspace is a suggestion I made > that N in -tabstat- should always, or at least > by default, be shown as an integer with no decimal places > whenever it was in fact an integer. But even that might not > be what was always wanted. On the other hand, the core of a program is only a few lines long: foreach v of var q7a q7b q7c { qui su `v' , detail di "`v'" "{col 18}" r(N) "{col 24}" %9.1f r(mean) "{col 34}" %9.0f r(p50) } Nick n.j.cox@durham.ac.uk * * 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/

**References**:**st: RE: Formatting Columns in Tabstat***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: Taboods** - Next by Date:
**Re: st: bootstrap with pweights** - Previous by thread:
**st: RE: Formatting Columns in Tabstat** - Next by thread:
**st: Formatting Columns in Tabstat** - Index(es):

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