I have a list of over 500 drug names, and I'm trying to write a loop to create a dummy variable for each individual drug. My data looks like this:
Drugname
I will then use those variables to search study abstracts using the strpos command to flag which studies evaluated which drugs. The current code is:
gen brentuximab=0
replace brentuximab = 1 if strpos(Abstract, "brentuximab")
I would rather not have to write 500+ lines of code and switch out the drug name for each, but I can't figure out how to create a loop to do this. I'm definitely open to other ways of doing it if you have any suggestions.
Thanks in advance!
Drugname
brentuximab |
tadalafil |
riociguat |
riociguat |
iobenguane |
iobenguane |
everolimus ... |
gen brentuximab=0
replace brentuximab = 1 if strpos(Abstract, "brentuximab")
I would rather not have to write 500+ lines of code and switch out the drug name for each, but I can't figure out how to create a loop to do this. I'm definitely open to other ways of doing it if you have any suggestions.
Thanks in advance!
Comment