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

RE: st: How to create a rank?

From   "Nick Cox" <>
To   <>
Subject   RE: st: How to create a rank?
Date   Mon, 3 Mar 2008 09:11:21 -0000

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.


Jeremy Miles

How about :

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


>  I am trying to create 'rank' based on total revenues. I used the
>  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:

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