Dear Stata altruistic,
These forum always encourage me to use Stata more and more. Thanks for your continuous support.
I'm working on antimicrobial resistance so I have individual antibiotic resistance status (1=Sensitive, 2= Intermediate, 3= Resistance) for different antibiotics (S_CN_10 S_MEM_10 S_ETP_10 S_IPM_10 S_FOX_30 S_F_300 S_TZP_110) like following table
Now want to generate a variable ASStatus to put all resistance status in the single variable so my code look like
[/CODE]
Problem is number of observations changed if any individual (UniqueID) fall in both group (ASStatus=1 & ASStatus=2) but I need something which calculate separately in each value label in the same variable (resistance status).
Helpful suggestion is appreciated.
These forum always encourage me to use Stata more and more. Thanks for your continuous support.
I'm working on antimicrobial resistance so I have individual antibiotic resistance status (1=Sensitive, 2= Intermediate, 3= Resistance) for different antibiotics (S_CN_10 S_MEM_10 S_ETP_10 S_IPM_10 S_FOX_30 S_F_300 S_TZP_110) like following table
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str11(PId UniqueId) double(S_CN_10 S_MEM_10 S_ETP_10 S_IPM_10 S_FOX_30 S_F_300 S_TZP_110) float(SampleTypeCat2 ASStatus) "TR001" "111011TR001" . . . . . . . 1 . "TR002" "111011TR002" . . . . . . . 1 . "TR003" "111011TR003" 1 1 1 1 1 1 1 1 . "TR004" "111011TR004" . . . . . . . 1 . "TR005" "111011TR005" 1 1 1 1 1 1 1 1 . "TR006" "111011TR006" 1 1 1 1 1 1 2 1 . "TR007" "111011TR007" . . . . . . . 1 . "TR008" "111011TR008" . . . . . . . 1 . "TR009" "111011TR009" 1 1 1 1 1 1 1 1 . "TR010" "111011TR010" 1 1 1 1 1 1 1 1 . end label values S_CN_10 S_CN_10 label def S_CN_10 1 ">=15", modify label values S_MEM_10 S_MEM_10 label def S_MEM_10 1 ">=23", modify label values S_ETP_10 S_ETP_10 label def S_ETP_10 1 ">=22", modify label values S_IPM_10 S_IPM_10 label def S_IPM_10 1 ">=23", modify label values S_FOX_30 S_FOX_30 label def S_FOX_30 1 ">=18", modify label values S_F_300 S_F_300 label def S_F_300 1 ">=17", modify label values S_TZP_110 S_TZP_110 label def S_TZP_110 1 ">=21", modify label def S_TZP_110 2 "18-20", modify label values SampleTypeCat2 SampleTypeCat2l label def SampleTypeCat2l 1 "Human", modify
Code:
gen ASStatus=. replace ASStatus=1 if S_CN_10==3 replace ASStatus=2 if S_MEM_10==3 | S_ETP_10==3 | S_IPM_10==3 replace ASStatus=3 if S_FOX_30==3
Problem is number of observations changed if any individual (UniqueID) fall in both group (ASStatus=1 & ASStatus=2) but I need something which calculate separately in each value label in the same variable (resistance status).
Helpful suggestion is appreciated.
Comment