Statalist


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

st: AW: Keeping trailing zeros when formatting a decimal


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Keeping trailing zeros when formatting a decimal
Date   Thu, 1 Oct 2009 13:41:30 +0200

<> 

http://www.stata.com/support/faqs/data/leading0.html


http://www.stata.com/support/faqs/data/leadingzeros.html





HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Donnerstag, 1. Oktober 2009 13:33
An: [email protected]
Betreff: st: Keeping trailing zeros when formatting a decimal

I would be very grateful for advice on the following basic formatting 
questions...

To store a number as a string with a format showing 2 significant 
figures, I do the following, for example:
di "`=string(-0.000029, "%9.2g")'"

If the second significant figure is a zero, how can I make sure this is 
still displayed?
The following produces:
. di "`=string(-0.0000201, "%9.2g")'"
-.00002
when I want it to display "-0.000020"

Also, how can I make sure it displays the zero before the decimal point?

Also, why does
. di "`=string(-0.000029, "%9.1g")'"
-.000029
not show only 1 significant figure?

Many thanks for your help.


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



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