Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Float or Double?


From   "Michael Mitchell" <[email protected]>
To   [email protected]
Subject   st: Float or Double?
Date   Tue, 23 Oct 2007 17:09:25 -0700

Greetings

  While showing someone the merits of "set type double", I encountered
the strangest thing. After entering "set type double", new non-integer
variables created via "generate" are created as doubles, but
non-integer variables created via "replace" are created as floats. For
example...

. desc

Contains data from hsb2.dta
  obs:           200                          highschool and beyond (200
                                                cases)
 vars:            11                          6 Feb 2007 12:41
 size:         3,200 (99.9% of memory free)
-------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
id              int    %9.0g
-------------------------------------------------------------------------------
Sorted by:

. set type double
. generate id2 = id / 5
. replace id = id / 5
id was int now float
(200 real changes made)

. desc

Contains data from hsb2.dta
  obs:           200                          highschool and beyond (200
                                                cases)
 vars:            12                          6 Feb 2007 12:41
 size:         5,200 (99.9% of memory free)
-------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
id              float  %9.0g
id2             double %10.0g
-------------------------------------------------------------------------------
Sorted by:
     Note:  dataset has changed since last saved

  Shouldn't both "id" and "id2" both be double?

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