I'm trying to rank companies by their profits. This is the kind of result I'm trying to create:
company | year | avg_profit | rank |
honda | 1970 | 10 | 1 |
honda | 1971 | 10 | 1 |
toyota | 1970 | 10 | 1 |
toyota | 1971 | 10 | 1 |
ford | 1970 | 11 | 2 |
ford | 1972 | 11 | 2 |
Code:
sort avg_profit company egen rank = rank(avg_profit), by(company) track
How do I get the correct ranks so that they are both tied (i.e. multiple companies can rank in 1st position) and grouped by company?
Related posts:
- https://www.statalist.org/forums/for...he-rank-option
- https://www.stata.com/statalist/arch.../msg00581.html
Thank you!
0 Response to Ranking variables with Tying and between Groups
Post a Comment