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]

RE: st: variable format


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: variable format
Date   Fri, 11 Mar 2011 11:10:15 +0000

What sounds like the same problem in a graphical context was raised a few days ago. See for one answer 

<http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1103/Author/article-131.html> 

Here are some golden rules in this territory. 

1. How a numeric value -- or more generally a numeric variable -- is stored in Stata is a matter of holding a binary approximation to numbers you are likely to think of as decimal. 

Some times, most notably if a value is integer, the approximation can be exact. 

Usually when there are fractional parts, the approximation is what it says: an approximation, typically very good but not exact. Multiples of .1, .01, .001, ... are a leading example. Most of them can not be held exactly and there is no "fix" to this mathematically inevitable fact by rounding to so many decimal places, whether directly or indirectly. 

2. How a value is displayed is quite distinct from how it is stored. 

3. Using a display format is the direct way to change how numbers are displayed. 

4. Changing the display format has absolutely no effect on the way numbers are stored. 

5. There can be good reasons to change numeric variables to string variables, but wanting a different display format is not among them. 

6. Read Bill Gould's blog entries 

http://blog.stata.com/tag/21x/

and/or what they reference and/or whatever -search precision- turns up if you want examples and details. 

Nick 
[email protected] 

Feiveson, Alan H. (JSC-SK311)

Hi - I have come across this problem before when I wanted to use the value of a variable or macro in a graphics title or axis label. Rounding doesn't work. I had to convert the values to strings and snip off the offending decimals (too much work).


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index