I wanted to categorize income variable, so I put the code as follows,
1)
gen inc_cate=.
replace inc_cate=0 if income==.
replace inc_cate=1 if income<100
replace inc_cate=2 if income>=100 & income<300
replace inc_cate=3 if income>=300 & income<500
replace inc_cate=4 if income>=500
However, when I tabulate the inc_cate value, I couldn't find inc_cate=0,
Instead, missing values were combined with inc_cate=4.
I use the other code, using "inrange"
2)
gen inc_cate=.
replace inc_cate=0 if income==.
replace inc_cate=1 if inrange(income,0,100) ....and so on
Then, value 0 appeard when I tabulate the variable
I don't understand why this happend.
1. How can I change the first code?(not using "inrange", and change missing values into "0")
2. Are there any better code when categorizing variable(what's the code to make "
income>=100 & income<300", when using "inrange")
Thank you in advance for your valuable advices.
0 Response to question about categorizing variable
Post a Comment