xtile() isn't ranking; it's binning. But observations with the same value will always be assigned to the same bin.
Other way round, this is a common question, even when the number of non-missing values is a multiple of the number of bins:
I asked for quantile-based bins. Why is the number of observations different in each?
The answer is always ties (plus the small print for non-multiples, as when 20 divided into 3 can at best be some permutation of 7 6 6).
More at
https://www.stata-journal.com/articl...article=dm0095 Section 6
https://www.stata-journal.com/articl...article=pr0054 Section 4
Other way round, this is a common question, even when the number of non-missing values is a multiple of the number of bins:
I asked for quantile-based bins. Why is the number of observations different in each?
The answer is always ties (plus the small print for non-multiples, as when 20 divided into 3 can at best be some permutation of 7 6 6).
More at
https://www.stata-journal.com/articl...article=dm0095 Section 6
https://www.stata-journal.com/articl...article=pr0054 Section 4
Comment