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

Re: st: How to display 10 digits data in data panel


From   Richard Williams <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: How to display 10 digits data in data panel
Date   Sat, 03 Sep 2005 18:42:22 -0500

At 06:00 PM 9/3/2005, [email protected] wrote:
for example:

set obs 1
gen vindex=2158
gen number=5746340000+2158

by stata default, not all the digits of "number" show up in the data panel.
therefore i use the syntax

format number %13.0g

to display all the digits. however, the result comes out weird. it is 5746342400
instead of 5746342158. why??????
See -help data_types-

"floats have about 7 digits of accuracy; the magnitude of the number does not matter. Thus, 1234567 can be stored perfectly as a float, as can 1234567e+20. The number 123456789, however, would be rounded to 123456792. In general, this rounding does not matter.

"If you are storing identification numbers, the rounding could matter. If the identification numbers are integers and take 9 digits or less, store them as longs; otherwise, store them as doubles. doubles have 16 digits of accuracy."

So in your case:

set obs 1
gen vindex=2158
gen double number=5746340000+2158




-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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