Hi,
I have some binary variables (TB, HIV, Diabetes) with yes/no answers. Is it possible to combine them into one called 'diseasegroups' that will contain all the individuals and combined groups? e.g.
tabulating diseasegroups will show the following categories:
TB
HIV
Diabetes
None
All
I tried the grouplabs method, but the result is different from what I am looking for.
I can do it manually, but it gets complex when there are too many variables to handle, that's why I am wondering if there is a more efficient way of doing this:
gen diseasegroups = "None"
replace diseasegroups = "TB" if TB == 1
replace diseasegroups = "HIV" if HIV == 1
replace diseasegroups = "Diabetes" if Diabetes == 1
replace diseasegroups = "All" if TB == 1 & HIV == 1 & Diabetes == 1
Thanks in advance for your insight!
Here is the dataex:
----------------------- copy starting from the next line -----------------------
I have some binary variables (TB, HIV, Diabetes) with yes/no answers. Is it possible to combine them into one called 'diseasegroups' that will contain all the individuals and combined groups? e.g.
tabulating diseasegroups will show the following categories:
TB
HIV
Diabetes
None
All
I tried the grouplabs method, but the result is different from what I am looking for.
I can do it manually, but it gets complex when there are too many variables to handle, that's why I am wondering if there is a more efficient way of doing this:
gen diseasegroups = "None"
replace diseasegroups = "TB" if TB == 1
replace diseasegroups = "HIV" if HIV == 1
replace diseasegroups = "Diabetes" if Diabetes == 1
replace diseasegroups = "All" if TB == 1 & HIV == 1 & Diabetes == 1
Thanks in advance for your insight!
Here is the dataex:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(TB HIV HBP Diabetes) 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 end label values TB Diabetes label values HIV V121 label def V121 0 "no", modify label def V121 1 "yes", modify label values HBP V122 label def V122 0 "no", modify label def V122 1 "yes", modify label values Diabetes V123 label def V123 0 "no", modify label def V123 1 "yes", modify
Comment