Hi all,
Beginner at stata and I'm trying to define a new variable (Ethnicity group into white, other, Unavailable) based on an existing string variable which has multiple ethnicities (Indian, Chinese, Caribbean, inc those those with unavailable records).
Would anyone be able to help with this, thanks
Patient |
ethnicity |
derived |
from all |
HES data | Freq. Percent Cum.
------------+-----------------------------------
Bangladesi | 298 0.17 0.17
Bl_Afric | 1,048 0.59 0.75
Bl_Carib | 1,642 0.92 1.67
Bl_Other | 532 0.35 2.03
Chinese | 400 0.22 2.25
Indian | 1,742 0.98 3.23
Mixed | 747 0.42 3.65
Oth_Asian | 1,028 0.58 4.22
Other | 1,783 1.00 5.22
Pakistani | 780 0.44 5.66
Unknown | 4,453 2.49 8.15
White | 103500 91.85 100.00
Beginner at stata and I'm trying to define a new variable (Ethnicity group into white, other, Unavailable) based on an existing string variable which has multiple ethnicities (Indian, Chinese, Caribbean, inc those those with unavailable records).
Would anyone be able to help with this, thanks
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 gen_ethnicity "White" "White" "White" "White" "White" "White" "White" "White" "White" "White" "White" end
ethnicity |
derived |
from all |
HES data | Freq. Percent Cum.
------------+-----------------------------------
Bangladesi | 298 0.17 0.17
Bl_Afric | 1,048 0.59 0.75
Bl_Carib | 1,642 0.92 1.67
Bl_Other | 532 0.35 2.03
Chinese | 400 0.22 2.25
Indian | 1,742 0.98 3.23
Mixed | 747 0.42 3.65
Oth_Asian | 1,028 0.58 4.22
Other | 1,783 1.00 5.22
Pakistani | 780 0.44 5.66
Unknown | 4,453 2.49 8.15
White | 103500 91.85 100.00

Comment