Statalist


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

RE: st: Errors in egen, total()


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Errors in egen, total()
Date   Mon, 14 Dec 2009 13:35:52 -0000

Dan's comment is on target. However, note that -recast- issued
retrospectively can do nothing by way of restoring lost precision. The
variable desired must be re-created using -egen- with -long- or -double-
specified explicitly. 

Nick 
n.j.cox@durham.ac.uk 

Dan Blanchette

floats have about 7 digits of accuracy so I think that's what
you're running into with rev = 28536717

Here's the documentation on data types:
http://www.stata.com/help.cgi?datatype

Try:
  . recast long rev

as long has up to 9 digits of accuracy.

> From: "Mike Kim" <kalisperos@gmail.com>
 
> I used "egen total()" to create "cumrev" like the following, but if
there is 
> only one week per title, total gives a slightly lower number than the 
> original number in some cases (1 or 2 lower). Any idea about why it
produces 
> different numbers?
> 
> bys title week: egen cumrev=total(rev)
> 
> title   week    rev                 cumrev
> A       707     28536717     28536716
> A       708     10                   30
> A       708     20                   30
> B        801    .....
> ......

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index