Hello,
I am trying to generate an income quantile variable using xtile. For some reason, the new variable has less levels with actual values than what I specify, and one level is all missing.
For example, if a generate the new variablw specifying n(5), I get 4 levels with values and one with all missing values. The original variable is a continous variable with lots of zeros.
sum Y_total
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
Y_total | 61665 4868.114 17333.08 0 199998
Here is an example of what is happening with my new variables:
. xtile Y_quart = Y_total, nq(4)
. tab Y_quart
4 quantiles |
of Y_total | Freq. Percent Cum.
------------+-----------------------------------
1 | 33,457 54.26 54.26
3 | 13,489 21.87 76.13
4 | 14,719 23.87 100.00
------------+-----------------------------------
Total | 61,665 100.00
The only way it seems to not-do this is if I set n(3), which generates:
xtile Y_quart2 = Y_total, nq(3)
. tab Y_quart2
3 quantiles |
of Y_total | Freq. Percent Cum.
------------+-----------------------------------
1 | 33,457 54.26 54.26
2 | 9,253 15.01 69.26
3 | 18,955 30.74 100.00
------------+-----------------------------------
Total | 61,665 100.00
Do you have any ideas what is causing this? I am using Stata SE 11.2
THANKS!!!
I am trying to generate an income quantile variable using xtile. For some reason, the new variable has less levels with actual values than what I specify, and one level is all missing.
For example, if a generate the new variablw specifying n(5), I get 4 levels with values and one with all missing values. The original variable is a continous variable with lots of zeros.
sum Y_total
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
Y_total | 61665 4868.114 17333.08 0 199998
Here is an example of what is happening with my new variables:
. xtile Y_quart = Y_total, nq(4)
. tab Y_quart
4 quantiles |
of Y_total | Freq. Percent Cum.
------------+-----------------------------------
1 | 33,457 54.26 54.26
3 | 13,489 21.87 76.13
4 | 14,719 23.87 100.00
------------+-----------------------------------
Total | 61,665 100.00
The only way it seems to not-do this is if I set n(3), which generates:
xtile Y_quart2 = Y_total, nq(3)
. tab Y_quart2
3 quantiles |
of Y_total | Freq. Percent Cum.
------------+-----------------------------------
1 | 33,457 54.26 54.26
2 | 9,253 15.01 69.26
3 | 18,955 30.74 100.00
------------+-----------------------------------
Total | 61,665 100.00
Do you have any ideas what is causing this? I am using Stata SE 11.2
THANKS!!!
Comment