I would like to replace a variable (cancer=1) when the variable string contains a partial match from the list of local words (see below).
use "file 1", clear
local words cancer malignancy metastatic
foreach w of local words {
replace cancer = 1 if strpos(term, "`w'")
}
QUESTION
*There are over 200 partial strings that could indicate cancer, I've started with 3 words to run the code to see if it works. Instead of writing out all 200 words under "local words" how do I refer to a separate file with a list of strings (file 2)?
use "file 1", clear
local words cancer malignancy metastatic
foreach w of local words {
replace cancer = 1 if strpos(term, "`w'")
}
QUESTION
*There are over 200 partial strings that could indicate cancer, I've started with 3 words to run the code to see if it works. Instead of writing out all 200 words under "local words" how do I refer to a separate file with a list of strings (file 2)?
Comment