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
STATA Econometrics modelHey guys, I have another question where I'd like to hear your opinion on. I am currently working on…
Make a new group variable of a variableHi! I probably got a simple problem. Let us say I got a variable, called States, with numbers from …
Changing the order of bars in a box plotHi! I want to make a box plot of distribution of 6 different scores (score 1-6) by a grouping varia…
Two digit year to four digit year for date makingHello Statalist, I need to use "gen start_date = mdy(month, day, year)" to get a date var. However, …
egen command not workingMy egen and count command is not working although I tried it with ssc install egen but it's still no…
Subscribe to:
Post Comments (Atom)
0 Response to extracting several string values from several different variables
Post a Comment