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: A bug in egen and gen?


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: A bug in egen and gen?
Date   Fri, 18 Feb 2011 11:49:59 +0000 (GMT)

--- On Fri, 18/2/11, Liao, Junlin wrote:
> Unless someone changed the command, my version of Stata 11
> does not compress double to float when it can do so.

I suspect something like this happened: You entered a number
like 4.1, tried to compress it, and nothing happened. Remember
that in binary numbers like 4.1 are like 1/3 in decimal. So 
it is like Stata is comparing 0.33330000 with 0.33333333 and 
says "that is not the same number, so I cannot compress that
variable". I guess that we would be willing to live with either 
but the computer cannot distinguish such a situation from another
where genuine information would be lost. In these situations 
Stata will choose the safe solution and only compresses when 
literaly no information would be lost.

*---------------------- begin example --------------------
// you can't compress 4.1
clear
set obs 1
gen double noncompress = 4.1
compress
desc

// why?
// 4.1 in double is not the same number as 4.1 in float:
di %21x 4.1
di %21x float(4.1)
*---------------------- end example ---------------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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