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

st: Determining the width of a formatted value


From   "Sayer, Bryan" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Determining the width of a formatted value
Date   Fri, 4 Apr 2003 12:38:15 -0500

I am a bit confused over how Stata determines what can fit into the width of
a formatted field (the w in w.d)  All references are Stata 8 on Windows 95.

I've generally used a comma 12.0 type format to display U.S. population
counts.  But I was using %12.0gc and I got

. display %12.0gc 123456789
   123456789

I've always assumed that 12 was enough spaces for hundreds of millions
including commas.  But apparently not with the %gc format.

In comparison %fc is fine,

. display %12.0fc 123456789
 123,456,789

The reference manual (A-F) page 394 states that %11.0gc is too small for
23,667,902 to display with commas, which does appear to be the case:
. display %11.0gc 23667902
   23667902
But %11.0fc is fine:
. display %11.0fc 23667902
 23,667,902

The User's manual on page 121 states that 10,000,000 with a %9.2fc format
will display
10,000,000.00
which is clearly incorrect
. display %9.2fc 10000000
 1.00e+07

It also states (page 121) that the f format will always display the same
number of decimal places , even if there is a loss in displayed precision.

So does the gc format keep a space for the decimal, while fc does not or
what?  %11.0gc should be fine for 23667902 in my mind, as that is only TEN
required spaces as far as I can tell.  How do I calculate the number of
digits that will display with the gc format?

Bryan Sayer
Statistician, SSS Inc.
[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