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]

st: Ranking observations of a variable across a set of variables


From   "Jennifer L. Milosch" <[email protected]>
To   [email protected]
Subject   st: Ranking observations of a variable across a set of variables
Date   Tue, 01 Nov 2011 20:24:55 -0700

Hello,
I am trying to find the rank of an observation of a variable across a set of variables. My data looks something like this:

x1|x2|x3|x4
50|10|30|60
20|60|10|40

I want to generate a variable for the rank of x1 compared to the values of x1, x2, x3, and x4 for each observation in the data. I have tried using

-bysort x1 x2 x3 x4: egen rank1=rank(x1)-

but it is returning a variable of all ones, which is not correct. Using the data above, I'm look for variables that are:

rank1|rank2|rank3|rank4
2 |4 |3 |1
3 |1 |4 |2

Any help would be much appreciated.


--
Jennifer L. Milosch
Ph.D. Candidate
Dept of Economics
UC Santa Barbara





*
*   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