Announcement

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

  • Drop duplicate pairs (X,Y; Y,X)

    Unfortunately, I was not able to find out how to drop a pair of duplicates. Let's say we have variables ID, X and Y and the data looks as follows:
    ID X Y
    1 1 2
    2 2 1
    3 3 5
    4 4 6
    I would like to identify ID1 and ID2 as a pair and drop ID2. However, this does not work with "duplicates". Do you have an efficient solution for this problem?

    Thank you!

  • #2
    you could use the user-written "rowsort" (SJ; use search to find and install) and then use duplicates (and then drop the new variables); see;
    Code:
    help rowsort

    Comment


    • #3
      https://www.stata-journal.com/articl...article=dm0043 explains.

      (Searching for mentions of dm0043 here will give you examples.)
      Last edited by Nick Cox; 24 Apr 2019, 09:01.

      Comment


      • #4
        Works like a charm, thanks!

        Comment


        • #5
          Harald, sounds like you got what you needed.

          For those coming afterwards, I will also point to two other posts here on Statalist that answer similar questions regarding creating a unique group or dyad identifier (they all use the same solution given in the Stata Journal article): See here and here

          Comment

          Working...
          X