Hi experts!

I have a four-year repeated cross-sectional data set. I want to divide my observations (within each year) into 400 equal-sized groups according to their income ranks. In addition, whenever there are ties, I want to assign ranks according to the value of another given variable.

I only know that we can do the following:

xtile newvar = income, n(400)

But xtile does not seem to allow me to introduce an additional variable to assign ranks when there are ties. Is there any simple method or user-written command? Thank you!