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]
RE: st: doubt on the output format %w.dg
From
Grace Jessie <[email protected]>
To
<[email protected]>
Subject
RE: st: doubt on the output format %w.dg
Date
Sat, 12 Mar 2011 16:19:10 +0000
NIck,
I had read the -help format- file several times before I asked the question and the examples are all from that.
I can understand %f very well, but %g is another thing.
Does "with %g you give up most of the control and let Stata decide" in your reply mean the result for %g is random?
Or else, what I want to know is how Stata dicides it.
Additionally, in the Users' Guide, it is said that "The %w.0g format is a set of formatting rules that present
the values in as readable a fashion as possible without sacrificing precision. The g format changes
the number of decimal places displayed whenever it improves the readability of the current value."
And it takes the followings for example which puzzle me also.
. di %9.0g sqrt(2)
1.414214
// The width of 1.414214 is 8. I think it should be 1.4142136 (with the width of 9) which gives less precision sacrifice.
. di %11.0gc 23667902
23667902
There are no commas. With regard to it, the explanation in the [D]Data Management is that "This number was too large for
Stata to insert commas and still respect the current width of 11." Why the current width is 11? It is 8 certainly, isn't it?
. di %12.0gc 23667902
23,667,902
Together with the question in the first posting, I hope for any help.
Thank you.
Grace
----------------------------------------
> Date: Sat, 12 Mar 2011 12:23:08 +0000
> Subject: Re: st: doubt on the output format %w.dg
> From: [email protected]
> To: [email protected]
>
> -help format- is the place to start. I think the main thing is not to
> expect the rules for %g formats to be much like those for %f formats.
> With %f, you keep most of the control; with %g you give up most of the
> control and let Stata decide.
>
> Nick
>
> >> From: [email protected]
>
> >> I can not understand the variables' output format %w.dg.
> >> How does Stata leave up to the format the number of digits to be displayed to the right of the decimal point if d equals 0 and not more than d digits will be displayed if d!=0.
> >> For example,
> >> What does "12.0g" mean?
> >> Why "di %12.0g 5231371222.139" or "di %12.1g 5231371222.139" equals "5231371222", not "5231371222.1"? (the width of "5231371222" is 10, not 12.)
> >> Why "di %12.0g 0.0000029394" equals "2.93940e-06", not "2.9394e-06"?
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/