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: Errors, lack if precision in carrying out operations for some observations


From   Daniel Feenberg <[email protected]>
To   [email protected]
Subject   Re: st: Errors, lack if precision in carrying out operations for some observations
Date   Sun, 15 May 2011 11:03:46 -0400 (EDT)


On Sun, 15 May 2011, Jan Keil wrote:

Dear Statalist,

I have the following problem:

Stata/SE 10.1 (Mac) does not undertake a simple operation on all of the 500,000 observations in my file (or does it with errors or not in a precise way).

I have 2 numeric variables, "gvkey" and "sid" (among others in the file) that are used to create a third, "id".

The commands are:

gen id = .
format id sid gvkey %16.2f
replace id = gvkey*1000 + sid


The result is that for some observations/rows the "id" variable is not calculated in a correct way.
Two examples are:

         id     gvkey    sid
31567000.00  31567.00   1.00
119653096.00 119653.00  99.00

The values for "id" should be instead:

         id     gvkey   sid
31567001.00  31567.00  1.00
119653099.00 119653.00 99.00



Try

  . generate double id = .

a -float- has only 5 or 6 digits of precision, the -format- doesn't affect the internal storage, only external representation.

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