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
Loop with consecutive numbersHello Stata community, I am trying to replace multiple id of a data set, where the ids are consecut…
Selecting dates within groups based on specific criteria in order to create a more unique idHello all, I'm a new Stata user and new to Statalist; I'm currently using StataMP 14. I'm doing so…
Pasting the data from Excel to Stata converts values of the variableDear Stata Members I am dealing with some financial data like income, total assets, etc. Many of the…
Selecting all dates within groups that are within one week of each other and creating a sub-group idHello all, I'm a new Stata user and new to Statalist; I'm currently using StataMP 14. Purpose: I'm…
Create new variable of survey dataHello. I'm working with survey data from the Eurobarometer survey. I want to create a new variable, …
Subscribe to:
Post Comments (Atom)
0 Response to extracting several string values from several different variables
Post a Comment