Hello,
I have a string variable (positiveassays) that contains a list of drugs and the levels of drugs detected in the specimen. I am trying to separate out the drug types into separate variables and remove the parentheses and the numeric values within the parentheses as well. Here is a sample of the cases i am working with:
I tried
and then
But that didnt work. I was trying to remove the parentheses and everything in them.
Any help would be greatly appreciated as always!
I have a string variable (positiveassays) that contains a list of drugs and the levels of drugs detected in the specimen. I am trying to separate out the drug types into separate variables and remove the parentheses and the numeric values within the parentheses as well. Here is a sample of the cases i am working with:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str544 positiveassays "Hydrocodone (388.264)" "Methamphetamine (246.86)" "Amphetamine (1600)" "Cocaine (800), Benzoylecgonine (800)" "THC (10.96)" "Methamphetamine (1600), Hydrocodone (29.156), Amphetamine (116.379)" "Methamphetamine (242.75)" "Codeine (275.445), Morphine (800), 6-MAM (40)" "Cocaine (564.218)" "Methamphetamine (249.92)" end
Code:
split positiveassays, parse(,) gen(drug)
Code:
replace drug1 = subinstr(drug1, "(*)", "", .)
Any help would be greatly appreciated as always!
Comment