Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Unique dyads

From   Nick Cox <>
Subject   Re: st: Unique dyads
Date   Fri, 15 Apr 2011 00:44:50 +0100

With numeric identifiers, id1 id2, or string identifiers id1 id2,

gen first = cond(id1 < id2, id1, id2)
gen second = cond(id1 > id2, id1, id2)
egen group = group(first second)

See my note as cited earlier. But I've not worked my way through the
FAQ to see if and why their method differs.


On Fri, Apr 15, 2011 at 12:18 AM, emanuele mazzini
<> wrote:
> Thanks for your reply. Well, not really. I mean, they are actually are
> the same thing, so I'm looking for a way to give "partnerA and
> partnerB" and "partnerB and partnerA" the same value of the variable
> dyad, since the one I mentioned before is not working. But I do need
> to take into account both the pairs and cannot exclude one of them as
> mine is an unbalanced panel, and I don't know if, for instance, the
> couple "partnerA and partnerB" is also listed as "partnerB and
> partnerA".
> Hope this can help for any further suggestion,
> Regards,
> Emanuele.
> 2011/4/14 Nick Cox <>:
>> I wrote something on this
>> SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
>>        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
>>        Q4/08   SJ 8(4):588--591                                 (no commands)
>>        tip on how to handle dyadic identifiers
>> Whether the UCLA FAQ came first I don't know. I wasn't aware of it
>> when I wrote.
>> That aside, I don't follow your detail but guess that there is just
>> one key point: if "partner A - partner B" is not equivalent to
>> "partner B - partner A", as for example if the first partner is
>> exporter and the second importer, then
>> egen id = group(partnerA partner B)
>> should suffice for unique identifiers.
>> Nick
>> On Thu, Apr 14, 2011 at 7:29 PM, emanuele mazzini
>> <> wrote:
>>> I am using an unbalanced dyadic panel dataset for which I need to
>>> generate an unique dyad id. I looked at this help:
>>> but the
>>> suggestions I found here do not seem to work in my dataset. In
>>> particular, the example shows that there is a certain symmetry, so
>>> that the couple for which a=1 and b=5 is the same couple for which a=5
>>> and b=1. Hence the couple considered gets the same value for the
>>> variable dyad. But this does not work in my dataset because the couple
>>> that gets a given value for the variables a and b is not the same
>>> couple that gets the same values for b and a.
>>> I can be more clear with the following example, which will be in terms
>>> of countries, as in my dataset. Suppose I consider the couple USA and
>>> GBR and I apply the suggested procedure. Then when the couple is:
>>> USA-GBR i got a=1 and b=75
>>> but when I consider the reverted couple, i.e GBR-USA, i got a=46 and
>>> b=90, which are absolutely not the same values, as the help i read
>>> suggest.
>>> Anyone can please help me to understand why this is happening or has
>>> an alternative way to proceed to get an unique dyad-id identifier?
>> *

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index