I am trying to generate a new variable with my income variable being sorted into deciles. I generated a new variable and when I tried to use if it always said "type mismatch". My original variable contains income such as 2.000 and so on... so it is a numeric variable. I used encode but the generate and replace command afterwards is not working. There are always zero changes made in var10_decile
encode var10,generate (var10_num)
gen var10_decile=.
replace var10_decile = 1 if var10_num <=2000
replace var10_decile = 2 if var10_num > 2000 & <= 2999
replace var10_decile = 3 if var10_num >2999 & <=3999
encode var10,generate (var10_num)
gen var10_decile=.
replace var10_decile = 1 if var10_num <=2000
replace var10_decile = 2 if var10_num > 2000 & <= 2999
replace var10_decile = 3 if var10_num >2999 & <=3999
Comment