Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Format summary table numbers with maximum of one decimal


From   Christoph Schnelle <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Format summary table numbers with maximum of one decimal
Date   Fri, 28 Mar 2014 21:23:28 +0000

Dear Statalist,

I am trying to create a summary with N, mean and sd showing no decimal for = the integer (N) and exactly one decimal for mean and sd in Stata 13 and I a= m not succeeding.

The closest I came is with:

sysuse auto
tabstat mpg, by(foreign) stat(n mean sd) nototal format(%9.1g)

foreign |         N      mean        sd
---------+------------------------------
Domestic |        52        20       4.7
Foreign |        22        25       6.6
----------------------------------------

Other summary command don't support formatting as far as I know and 'format=  (%9.1f)' leads to N having a decimal.

tabstat mpg, by(foreign) stat(n mean sd) nototal format(%9.1f)

Summary for variables: mpg
     by categories of: foreign (Car type)

foreign |         N      mean        sd
---------+------------------------------
Domestic |      52.0      19.8       4.7
Foreign |      22.0      24.8       6.6
----------------------------------------

Is the fact that %9.1g shows no decimal for mean a bug or a feature?
Is there a way to achieve what I am looking for (zero decimals for integers= , one decimal for non-integer numeric)?

Warm Regards,

Christoph Schnelle

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index