Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Data types, collapse & egen


From   "Eric G. Wruck" <ewruck@econalytics.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Data types, collapse & egen
Date   Mon, 12 Sep 2005 12:50:25 -0400

In a .do file, I generate a double-precision value variable (price x quantity). I then aggregate, using the collapse command, by ticker symbol & year. It seems collapse won't allow me to specify data type but that's probably fine since it chose double for this variable as well. As a final step, I want to be able to report the value of trades as a percentage of all trades conducted in a year. Here I use egen

egen double yrtot = total(rev), by(year)

But instead of values such as 1,045,855,825 I get 1,046,000,000 instead. I looked at help for double & learned that the min & max values for that data type are enormous. In fact, Stata tells me:

Closest to
Storage 0 without
type Minimum Maximum being 0 bytes
----------------------------------------------------------------------
byte -127 100 +/-1 1
int -32,767 32,740 +/-1 2
long -2,147,483,647 2,147,483,620 +/-1 4
float -1.70141173319*10^38 1.70141173319*10^36 +/-10^-36 4
double -8.9884656743*10^307 8.9884656743*10^307 +/-10^-323 8



So I don't understand why I am getting this rounding. I would certainly appreciate help.

Thanks,

Eric


--

===================================================

Eric G. Wruck
Econalytics
2535 Sherwood Road
Columbus, OH 43209

ph: 614.231.5034
cell: 614.330.8846
eFax: 614.573.6639
eMail: ewruck@econalytics.com
website: http://www.econalytics.com

====================================================
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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