Dear Statalists,
I am running into a problem when generating percentile rank for each individual. Suppose I have sorted by group_id and income, my data set goes like:
group_id inidividual_id income nb
1 11 1000 0
1 12 1100 1
1 13 1100 1
2 21 1350 3
2 22 1400 4
3 31 1450 5
3 32 1500 6
3 33 1600 7
4 41 1620 8
4 42 1700 9
The definition of percentile rank is rank_i=n_b/N
n_b, number of individuals with income lower than income_i
N, total number of individuals in the group.
I have tried count, but it can only return one value and could not get nb correctly. Any suggestions will be welcomed. Thank you!
Ruth
I am running into a problem when generating percentile rank for each individual. Suppose I have sorted by group_id and income, my data set goes like:
group_id inidividual_id income nb
1 11 1000 0
1 12 1100 1
1 13 1100 1
2 21 1350 3
2 22 1400 4
3 31 1450 5
3 32 1500 6
3 33 1600 7
4 41 1620 8
4 42 1700 9
The definition of percentile rank is rank_i=n_b/N
n_b, number of individuals with income lower than income_i
N, total number of individuals in the group.
I have tried count, but it can only return one value and could not get nb correctly. Any suggestions will be welcomed. Thank you!
Ruth
Comment