Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

RE: st: A bug in egen and gen?

From   Maarten buis <>
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
set obs 1
gen double noncompress = 4.1

// 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: )

-- Maarten

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


*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index