Statalist The Stata Listserver


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

RE: st: RE: formatting for significant figures


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: formatting for significant figures
Date   Wed, 10 May 2006 14:47:48 +0100

Your wanting to omit leading zeros seems the 
tricky bit. 

There may well be a better way, but you 
can fudge this by 

. gen rnd = uniform()
. gen s_rnd = "." + string(round(1000 * rnd), "%04.0f")
. l rnd s_rnd

Nick 
n.j.cox@durham.ac.uk 

b. water
 
> Thank you Maarten for your suggestion. This is what I obtained:
> 
> . format trite %9.2e
> 
> . l trite in 1/5, clean
> 
>           trite  
>   1.   4.10e-03  
>   2.   4.75e-03  
>   3.   3.80e-03  
>   4.   4.82e-03  
>   5.   7.83e-03  
> 
> Actually what I wanted was to be able to display like (and I 
> concoct this):
> 
>  1.   .0041 
>  2.   .0047 
>  3.   .0038 
>  4.   .0048 
>  5.   .0078 
> 
> When I refer back to the manual [U] 15.5, it stated putting 
> an optional 0 to retain leading zeros, so I tried format 
> trite %09.2e, which did not give a different result from what 
> you have given. But when I did %09.2g it did! Problem solved.
 
M.Buis@fsw.vu.nl
 
> > -format trite %9.2e-

b. water
 
> Stata 8.2,
> 
> Is there a way to format numericals results for significant figures. For example:
> 
> . sysuse auto
> 
> . gen trite=price/1000000
> 
> . l trite in 1/10, clean
> 
>          trite 
>   1.   .004099 
>   2.   .004749 
>   3.   .003799 
>   4.   .004816 
>   5.   .007827 
>   6.   .005788 
>   7.   .004453 
>   8.   .005189 
>   9.   .010372 
>  10.   .004082 
> 
> How can I format trite to display just 2 (or any number in general) significant figures? I looked at [R] Format,  [U] 15.5, help format, searched the list using 'signifcant figures' and Googled 'stata significant figures' but without success. Appreciate advice/help.

*
*   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