Bookmark and Share

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


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

Re: st: EGEN GROUP where order doesn't matter?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: EGEN GROUP where order doesn't matter?
Date   Sat, 12 Feb 2011 10:07:45 +0000

As I understand you, you seek a group identifier and your rules are
that (e.g.) x_1 = 1 and x_2 = 2 are equivalent to x_2 = 1 and x_1 = 2.
If so, -egen, group()- will not do what you want and there is no
subverting it to do so through an option. Same point with any number
of variables.

You need another method. Perhaps -egen, rowtotal()- will do. Or you
need to sort your variables across rows first so that you apply -egen,
group()- to the row-sorted identifier data.

There was a review of row stuff in

SJ-9-1  pr0046  . . . . . . . . . . . . . . . . . . .  Speaking Stata: Rowwise
        (help rowsort, rowranks if installed) . . . . . . . . . . .  N. J. Cox
        Q1/09   SJ 9(1):137--157
        shows how to exploit functions, egen functions, and Mata
        for working rowwise; rowsort and rowranks are introduced

Nick

Brandon, a.k.a. Don Ruby <[email protected]> wrote:

> Note, I have 4-tuple identifiers, not just a pair.


>> I understand that egen id=group(id1 id2) will create a list such that
>> the pair (id1.1 id2.1)=1, (id1.2 id2.2)=2 etc. But, the order of the
>> pair (id1 id2) matters so that the pair (id1.1 id2.1) will not yield
>> the same value as (id2.1 id1.1).
>>
>> How can i make it so that the same value is generated, regardless of
>> the varlist order?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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