Hello, i am working with treatment data i have treatment1 treatment2 treatment3 treatmentn variables which contain the name of the drugs taken by the patient.
i wish to generate a variable that would be called antihypertensives that would take the value 1 if any of treatment1 treatment2 treatment3 treatmentn lists any of a long list of antihypertensive molecules.
i tried looping and strpos as under
for each treatment of varlist treatment1 treatment2 treatment3 {
gen antihypertensive=1 if strpos(`treatment', ""ATENOLOL" "NICARDIPINE" "BISOPROLOL" "IBERSARTAN" "HYDROHLOROTHIAZIDE" )>0
}
i get an error message r(198)
what is the solution for this problem?
thanks for your help
Related Posts with extracting several string values from several different variables
Panel data analysisHi evryone. What is wrong in may data? I cannot do xtpcse analysis. Please HELP!!!. …
summarize variable by group with max and min valuesHi, How can I summarize a variable by group including maximum and minimum value? This only calcula…
Multiple regression analysis bachelor thesis HelpDear Stata experts, I currently am writing my bachelor thesis regarding the topic International Joi…
Exponentially Weighted Moving Average (EWMA) Control ChartHi Statalisters I was wondering if anyone can share example codes for graphing Exponentially Weight…
Average marginal effects of the structural model using gsemHello everybody! Currently, I am fitting a structural equation model using gsem in Stata 16. My c…
Subscribe to:
Post Comments (Atom)
0 Response to extracting several string values from several different variables
Post a Comment