Announcement

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

  • Merging data without sorting?

    Hi all,

    I apologize in advance if this is a rudimentary question. I've always been under the impression that your data must be sorted by the variable(s) you are merging on to merge successfully. Recently I've noticed that I have merged data, with seemingly correct results, without sorting in advance. Is this only because the data is sorted by default? Is my final result incorrect?

    I was under the impression that Stata would return an error message if not sorting, but I am not having this result.


    Thanks in advance!

  • #2
    Sorting is not required. The full documentation for the merge command linked to from the top of the output of help merge has a section titled Sort Order which discusses this at length.

    There is one exception where sorting makes a difference — merge m:m — but that version of merge is such a bad idea that even the documentation recommends against it, and experience is that whether you sort or not, the results are unlikely to solve the problem that led you to use it.

    Comment

    Working...
    X