Statalist


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

st: Ranking observations within groups


From   "James Cross" <jcross@tcd.ie>
To   statalist@hsphsun2.harvard.edu
Subject   st: Ranking observations within groups
Date   Thu, 11 Dec 2008 15:04:16 +0000

Hi Statalisters,

I have a variable that represents different actors positions on
different issues (groups). So I have around 30 positions between 0 and
100 for each individual issue within the variable with quite a few
ties. I want to create a variable that ranks these observations in
ascending order so that the lowest observation(s) will have a value of
1 in the new variable, the second lowest observation(s) will have a
value of 2 and so on.

I have tried -by issue_var: egen newvar = rank(oldvar), track- but
this returns a newvar in which the lowest variable is given 1st
position, which is fine, but if there are say 3 ties for position 1,
the second lowest oldvar is ranked in 4th position rather than 2nd
position which is what I need. Any ideas as to how I could create a
newvar where ties do not change the rank position of following
observations within each group?
-- 
Best Regards,

James Cross
*
*   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   |   What's new   |   Site index