Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loops: Creating Dummy Variables from List of Drug Names

    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
    brentuximab
    tadalafil
    riociguat
    riociguat
    iobenguane
    iobenguane
    everolimus
    ...
    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!

  • #2
    Repeated post. If interested please follow https://www.statalist.org/forums/for...-of-drug-names

    Comment

    Working...
    X