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

st: RE: A strange data problem


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: A strange data problem
Date   Mon, 17 Jan 2005 08:56:30 -0000

It is clear from -describe- that you have successfully transferred UPC as a double. However, you have generated the new variable UPC1 as a float - losing some of the precision of UPC. To create a variable UPC1 that is identical to UPC, you need:

gen double UPC1=UPC

See the manuals for [U] 16.10 Precision and problems therein.

David
[email protected]

-----Original Message-----
From: Maoyong Fan [mailto:[email protected]]
Sent: 16 January 2005 06:16
To: statalist
Subject: st: A strange data problem


Dear Stata User,

        I met a strange problem in dealing with my scanner data.  I use stata transfer to transger the original data to dta files.  One of my variables is UPC whose storage type is double.  I found that when I generate a new variable equal to UPC, the new variable is totally different from UPC.

Like this:
gen UPC1 = UPC
gen diff = UPC1 - UPC
sum
des

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         UPC |   1780770    3.76e+10    1.96e+11   1.00e+10   2.72e+12
        UPC1 |   1780770    3.76e+10    1.96e+11   1.00e+10   2.72e+12
        diff |   1780770    144.9445    4290.722    -105114     116086

. des

Contains data from D:\temp\dairyHH1.dta
  obs:     1,780,770                         
 vars:             3                          18 Jun 2003 13:27
 size:    35,615,400 (66.0% of memory free)
-------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
UPC             double %15.0g                 UPC -
                                                system/generation/vendor/item
UPC1            float  %9.0g                 
diff            float  %9.0g                 
-------------------------------------------------------------------------------
Sorted by: 
     Note:  dataset has changed since last saved

Anyone know what's wrong with this?    

Warm regards,

Maoyong Fan



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


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