【发布时间】:2021-09-22 14:39:55
【问题描述】:
我有这个变量接受这些值:
tab expenditure
Q11 | Freq. Percent Cum.
--------------------------------+-----------------------------------
Afs 2500-5000 | 24 3.84 3.84
Afs 5000-7500 | 89 14.24 18.08
Afs 7500-10000 | 235 37.60 55.68
I don't know / refuse to answer | 9 1.44 57.12
Less than Afs 2500 | 5 0.80 57.92
More than Afs 10000 | 263 42.08 100.00
--------------------------------+-----------------------------------
Total | 625 100.00
我想更改排序,所以类别不是按字母顺序排列的。我尝试使用
label define expenditure 1 "Less than Afs 2500" 2 "Afs 2500-5000" 3 "Afs 5000-7500" 4 "Afs 7500-10000" 5 "More than Afs 10000" 6 "I don't know / refuse to answer", replace
我也尝试过使用
recode expenditure (1 = 5) (2 = 1) (3 = 2) (4 = 3) (5 = 6) (6 = 4)
但是,这两种方法都只是更改了标签,而不是基础数据,现在数据都搞砸了(注意频率的变化,现在“超过 Afs 10000”类别的观测值只有 24 个,而不是之前的 263 个)。
tab expenditure
Q11 | Freq. Percent Cum.
--------------------------------+-----------------------------------
Less than Afs 2500 | 89 14.24 14.24
Afs 2500-5000 | 235 37.60 51.84
Afs 5000-7500 | 9 1.44 53.28
Afs 7500-10000 | 263 42.08 95.36
More than Afs 10000 | 24 3.84 99.20
I don't know / refuse to answer | 5 0.80 100.00
--------------------------------+-----------------------------------
Total | 625 100.00
发生了什么事?在不影响我的基础数据的情况下,我可以做些什么来改变它?
【问题讨论】:
标签: stata categorical-data recode