Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: How to create a rank?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to create a rank?
Date   Sun, 2 Mar 2008 17:31:13 -0000

As you want a rank, I suggest the use of -egen, rank()-. 

-egen, group()- is only going to produce an equivalent result if there
are no ties. 

You get rank of 1 for highest by negating the variable: 

drop rank 
egen rank = rank(-revenue) 

This point and related stuff are discussed in 

http://www.stata.com/support/faqs/stat/pcrank.html

Nick 
[email protected] 

Song (a.k.a. Reo) 

I am trying to create 'rank' based on total revenues. I used the following 
command:

sort revenue
egen rank=group(revenue)

The result is that the smallest revenue is 1 and the highest revenue is 100, 
for example. How can I reverse the rank? I want the highest revenue to be 
number '1'.


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index