Seems the unique option does what you describe you need.
clear
webuse machine.dta
drop operator
bysort machine: egen rank = rank(output)
bysort machine: egen rankf = rank(output), field
bysort machine: egen rankt = rank(output), track
bysort machine: egen ranku = rank(output), unique
sort machine output
list, clean
On Dec 11, 2008, at 9:04 AM, James Cross wrote:
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/
*
* 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/