I am trying to come up with percentile groups using the code below
Code:
_pctile asset_index, nquantiles(100) return list forval i=1/99 { local p`i' = (r(r`i')) } gen percent = . replace percent = 1 if asset_index < `p1' replace percent = 100 if asset_index > `p99' & asset_index < . forval i=1/98 { di "``i''" local j = `i' + 1 di "lower `p`i''" di "upper `p`j''" replace percent = `i' + 1 if inrange(asset_index, `p`i'', `p`j'') } ta percent
Am attaching the dataset since
Code:
dataex
Any advice is welcome.
Thanks in advance!
0 Response to Unequal number of observations in percentile groups
Post a Comment