Dear Statalisters,
I'm using Stata 13.1 and I have a file with columns x1 and x2
I want generate a 3rd variable, x3, that gives me the rank of observations according to the value of x2, by the value of x1. There are no ties in X2.
I have almost got this using:
rank= rank(x2), by(x1)
the trouble is that I want the order so that x3=1 for the highest value of x2 but Stata gives it the other way around. This would be easy to fix if X1 had the same range, say 1-15, each time, but it does not.
How can get a rank in the reverse order?
Thank you very much for any suggestions!
Pavel
I'm using Stata 13.1 and I have a file with columns x1 and x2
I want generate a 3rd variable, x3, that gives me the rank of observations according to the value of x2, by the value of x1. There are no ties in X2.
I have almost got this using:
rank= rank(x2), by(x1)
the trouble is that I want the order so that x3=1 for the highest value of x2 but Stata gives it the other way around. This would be easy to fix if X1 had the same range, say 1-15, each time, but it does not.
How can get a rank in the reverse order?
Thank you very much for any suggestions!
Pavel
Comment