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]

st: A bug in egen and gen?


From   "Liao, Junlin" <junlin-liao@uiowa.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: A bug in egen and gen?
Date   Thu, 17 Feb 2011 18:09:57 +0000

I happen to notice a problem with the egen and gen commands. I'm using STATA 2011 SE (64 bit). I do not know if this problem exists in other versions. Please run the following commands to reproduce the problem:

clear
set obs 5
generate y=83085733
generate long z=83085733
egen y_mean=mean(y)
egen z_mean=mean(z)
egen long y_mean_long=mean(y)
egen long z_mean_long=mean(z)
format %10.0g y z  y_mean z_mean y_mean_long z_mean_long
list

By default, both egen and gen command use float for the size of the number and the values generated are not correct. However, if we restrict the numbers to be long integer, we can get correct results.

Anybody else noticed the bug? Is there an explanation for what happens? Thanks,

Junlin Liao




________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________

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