Announcement

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

  • -merge- evaluates keep()-option differently between Stata 13 and Stata 12

    Dear Statalisters,

    I recently ran into a quite strange error when using an (old and awkward) ado file that was written for Stata 12. The point is: -merge- seems to evaluate a "1:1" constraint regardless of the -keep()- option in Stata 13, but did not so in Stata 12.

    It took me a while to figure out what went wrong, but finally, here is a working example.
    Code:
    clear
    tempfile using
    
    // note this is a -long- file, but observations with
    // -id-s 1 or 2 only occur uniquely
    input    id    spell
        1    1
        2    1
        7    1
        7    2
        7    3
        8    1
        8    2
        8    3
    end
    save "`using'"
    clear
    
    // note this is a simple, cross-sectional file
    // (one observation per id)
    input    id
        1
        2
    end
    
    // this -merge- works in Stata 12 (unexpectedly?)
    // and does not in Stata 13 (as to be expected)
    // it does neither work in Stata 13 prefixed by "version 12 : "
    merge 1:1 id using "`using'" , keep(match)
    The point seems to be: the "1:1" constraint holds when only looking at the matched observations; thus, Stata 12 executes everything.
    In Stata 13, however, the execution order seems to be different: the "1:1" part is checked on the whole data set, which must fail.

    Questions: Is this change in -merge-
    • intended,
    • documented somewhere and, more importantly,
    • does it indicate a major overhaul in -merge- that may also have influences in other areas?
    • Why does a "version 12" in Stata 13 not make -merge- behave as it had in Stata 12?
    Regards
    Bela
    PS: I had this issue hanging around for quite some time. Only the new forum made me think again about posting it, just to try the new platform. Talking about this: Congratulations to all persons involved - it feels great.
    Last edited by Daniel Bela; 01 Apr 2014, 10:32.

  • #2
    Daniel Beta notes that merge in Stata 13 now takes 1:1 more seriously than did Stata 12. In particular, merge now verifies that the identifiers in each dataset are unique before matching. In Stata 12, if keep() and 1:1 were specified together, the verification of uniquness was done on the merged result, not the inccoming datasets.


    Originally posted by Daniel Bela View Post
    Questions: Is this change in -merge-
    • intended,
    • documented somewhere and, more importantly,
    • does it indicate a major overhaul in -merge- that may also have influences in other areas?
    • Why does a "version 12" in Stata 13 not make -merge- behave as it had in Stata 12?

    Regards
    Bela

    PS: I had this issue hanging around for quite some time. Only the new forum made me think of posting it again, just to try the new platform. Talking about this: Congratulations to all persons involved - it feels great.
    The new behavior is intended, should have been documented in help whatsnew but wasn't, is not a major overhaul but a bug fix, and the version 12 prefix does not restore buggy behavior.

    --- Bill (StataCorp)

    Comment


    • #3
      Dear Bill,

      Originally posted by Bill Gould (StataCorp) View Post
      The new behavior is intended, should have been documented in help whatsnew but wasn't, is not a major overhaul but a bug fix, and the version 12 prefix does not restore buggy behavior.
      thanks for clarification. I obviously did not think of interpreting the behavior of 12 as buggy; when doing so, not resembling this behavior with the version 12 prefix of course makes perfect sense.

      Regards
      Bela

      Comment

      Working...
      X