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

st: RE: Formatting Columns in Tabstat


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Formatting Columns in Tabstat
Date   Sun, 16 Jun 2002 18:01:05 +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?

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. 

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/



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