Dear Statalist members,
I am trying to remove a part of my name variable if it contains 'DEAD'. This is an example of my data:
name
AAH DEAD
AB AIRLINES DEAD
AB CONSULTING
AB DYNAMICS
AB ELTN.PRDS.
ABACUS GROUP DEAD
Desired result:
name
AAH
AB AIRLINES
AB CONSULTING
AB DYNAMICS
AB ELTN.PRDS.
ABACUS GROUP
Essentially, I need a code that removes ' DEAD' if an observation contains it. I have tried the code below, but that removes the entire name of the company and results in empty observations for companies that had 'DEAD' in their names.
replace name = substr(name, 1, strpos(name,"DEAD")-1)
Thank you for your help!
I am trying to remove a part of my name variable if it contains 'DEAD'. This is an example of my data:
name
AAH DEAD
AB AIRLINES DEAD
AB CONSULTING
AB DYNAMICS
AB ELTN.PRDS.
ABACUS GROUP DEAD
Desired result:
name
AAH
AB AIRLINES
AB CONSULTING
AB DYNAMICS
AB ELTN.PRDS.
ABACUS GROUP
Essentially, I need a code that removes ' DEAD' if an observation contains it. I have tried the code below, but that removes the entire name of the company and results in empty observations for companies that had 'DEAD' in their names.
replace name = substr(name, 1, strpos(name,"DEAD")-1)
Thank you for your help!
Comment