Reputation: 1
I have district level data grouped within town level data with voter turnout. I want to regroup or rank the towns with highest voter turnout in each district.
Upvotes: 0
Views: 20207
Reputation: 37208
To rank in descending order, just negate the variable (or more generally the expression) on which you are ranking.
sysuse auto
egen rank = rank(-mpg)
Stata's default is to rank in ascending order. But a minus sign is sufficient to reverse that.
In your case, it sounds like
egen rank = rank(-turnout), by(district)
Upvotes: 7