Statalist


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

Re: st: How to create a rank?


From   "Song" <[email protected]>
To   <[email protected]>
Subject   Re: st: How to create a rank?
Date   Mon, 3 Mar 2008 21:57:51 -0600

Thank you. I solved my problem. By the way, if there exist ties, egen rank = rank(revenue) also creates a problem. In my case, the command produced ***.5, etc. instead of a whole number.

Reo.

----- Original Message ----- From: "Nick Cox" <[email protected]>
To: <[email protected]>
Sent: Monday, March 03, 2008 3:11 AM
Subject: RE: st: How to create a rank?



As mentioned in my earlier posting, this fixes the reversal but does the
wrong thing in the presence of ties.

For ranks, use -egen, rank()-. It's as simple as that.

Nick
[email protected]

Jeremy Miles

How about :

gen revenue_reversed = revenue * -1
sort revenue_reversed
egen rank=group(revenue_reversed)

Song

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