Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is this message from reshape cmd: "Values would be changed"

    I use "reshape long", and get a message which is not explained in the manual: "<n> values would be changed; not changed".
    What does this mean?

    Setup: Three Excel files, imported (using import excel) and appended into one data file, containing a single column of one-decimal numbers, and five columns of dimensions (Geography, year, age, sex, type). If I select one of the number cells in the data editor and look at the value in the viewing field above the data table, the number has only one decimal.
    The "type" has two categories (string values: egen, lege). I want to have the number values for these two categories summed, over the groups defined by the four other dimensions, and the new values shall have their own "type" (all).

    So I do this:

    reshape wide number, i(GEO YEAR AGE SEX) j(type) string
    generate numberall = numberegen + numberlege
    reshape long

    The first reshape splits the number column into two, and at the same time the numbers acquire a bunch of decimals which were not present before. E.g., the number 4.9 might now look like 4.900000095367. This is not a problem, and Stata says nothing about it.
    The second reshape takes the data set back to the original long form, but (intelligently) includes the new type "all" - just what I wanted.

    QUESTION:
    In the second reshape, Stata does not do anything to the numbers. However, it issues a message in the report from reshape - the second and third lines below:

    (note: j = all egen lege)
    numberegen: 27 values would be changed; not changed
    numberlege: 371 values would be changed; not changed

    Data wide -> long
    -----------------------------------------------------------------------------
    Number of obs. 3120 -> 9360
    Number of variables 7 -> 6
    j variable (3 values) -> type
    xij variables:
    numberall numberegen numberlege->number
    -----------------------------------------------------------------------------

    What does Stata mean by "values would be changed"? It DID change values the first time, without mentioning it...



  • #2
    Working backwards:

    Stata did not change your values. They just look different. This is a precision issue: for enlightenment,

    Code:
    search precision
    and read as inclined. In a nutshell, what is the exact binary equivalent of 4.9? There isn't one, so Stata has to approximate. The Zen-like answer is

    what is displayed is not what is stored; what is stored is not what is displayed
    On the main issue, the answer probably lies in your use of different storage types. Show us the results of

    Code:
     
    describe numberall numberegen numberlege

    Comment

    Working...
    X