Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Identify combinations without respect to the order of the elements


From   Oliver Jones <ojones@wiwi.uni-bielefeld.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Identify combinations without respect to the order of the elements
Date   Wed, 13 Jul 2011 20:28:11 +0200

Hi everybody,

someone just sent me an solution to my private email:
------------------------------------------------------------------------------------------
One way to solve the problem would be to create two new variables which have a standard order for the cities. Then you can use egen group to identify the pairs.

That is:

gen first = var1 if var1 <= var2
replace first = var2 if first == ""

gen second = var2 if var1 <= var2
replace second = var1 if second == ""

egen paired = group(first second)
------------------------------------------------------------------------------------------

To my example with the cities var1 would be the variable from and var2 would be the
variable to.

Best
Oliver
--
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
- -
Bielefeld University
Faculty of Business Administration and Economics
Chair of Econometrics and Statistics
- -
Raum / room:  V9-110
Tel / phone:  +49 (0)521 106 4871
---
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index