I have a data set which includes information on 1000's of research participants health problems/long-term conditions. I have a variable already (called mmcount) that counts how many conditions each individual has.
Code:
tab mmcount
mmcount | Freq. Percent Cum.
------------+-----------------------------------
0 | 182,767 36.98 36.98
1 | 161,646 32.71 69.69
2 | 89,106 18.03 87.72
3 | 38,537 7.80 95.52
4 | 14,310 2.90 98.42
5 | 5,069 1.03 99.44
6 | 1,813 0.37 99.81
7 | 644 0.13 99.94
8 | 197 0.04 99.98
9 | 65 0.01 99.99
10 | 17 0.00 100.00
11 | 9 0.00 100.00
12 | 1 0.00 100.00
13 | 1 0.00 100.00
------------+-----------------------------------
Total | 494,182 100.00Code:
tab MMcount_5levels
MM count by 5 levels: |
0,1,2,3,4 or more | Freq. Percent Cum.
-------------------------------+-----------------------------------
0 long-term conditions | 182,767 36.98 36.98
1 long-term condition | 161,646 32.71 69.69
2 long-term conditions | 89,106 18.03 87.72
3 long-term conditions | 38,537 7.80 95.52
4 or more long-term conditions | 22,126 4.48 100.00
-------------------------------+-----------------------------------
Total | 494,182 100.00What I have tried so far doesn't work as it has the same groups as the variable above:
Code:
gen MMcount_5new=.
(494182 missing values generated)
. replace MMcount_5new = 1 if mmcount == 0
(182767 real changes made)
. replace MMcount_5new = 2 if mmcount >= 1
(311415 real changes made)
. replace MMcount_5new = 3 if mmcount >= 2
(149769 real changes made)
. replace MMcount_5new = 4 if mmcount >= 3
(60663 real changes made)
. replace MMcount_5new = 5 if mmcount >= 4
(22126 real changes made)
.
. label define MMcount_5new 1 "0 long-term conditions" 2 ">=1 long-term condition" 3 ">=2 long-term conditions" 4 ">=3 long-term conditions" 5 ">=4
> or more long-term conditions"
. label value MMcount_5new MMcount_5new
. label variable MMcount_5new "MM count by 5 levels: 0,1,2,3,4 or more"
. tab MMcount_5new
MM count by 5 levels: 0,1,2,3,4 |
or more | Freq. Percent Cum.
---------------------------------+-----------------------------------
0 long-term conditions | 182,767 36.98 36.98
>=1 long-term condition | 161,646 32.71 69.69
>=2 long-term conditions | 89,106 18.03 87.72
>=3 long-term conditions | 38,537 7.80 95.52
>=4 or more long-term conditions | 22,126 4.48 100.00
---------------------------------+-----------------------------------
Total | 494,182 100.00
0 Response to I want to create a new variable that can double count some observations
Post a Comment