Goog Afternoon Statalist users,
I have a database that looks like the following:
Example generated by -dataex-. To install: ssc install dataex
clear
input str100 Politician
"Arthur Alexander (Wilson Center), Hugh Patrick (Wilson Center)"
"Milt Drucker (Director Summit of the Americas, U.S. Department of State)"
"John Sequeira (State Department, Office of Southern Africa Affairs), Ltc Greg Saunders (DOD, Office "
"Mr. Nakamura (president, Kawasaki Steel America)"
"Steven A. Thompson (Professional Staff Member), Roger Smith (House National Security Committee (HNSC"
"S. Chami of Kenya (Ambassador ), Mr. W. Imakando (Embassy of Zambia), Mr. S. Dlamini (Embassy of Swa"
"Randi Sutton,Texas Governor George Bush, Cheryl Parker Rose, Florida
Governor Lawton Chiles (D)."
"Matt Mcmanus (Acting Division Chief, Energy-Producer Country Affairs, U.S. Department of State)"
end
I need to separate the names on each string. My first thought was to separate them by commas, but as you can see there are some commas between parenthesis that would separate things different of names so I need to replace the commas that are between parenthesis to other character and then split the string.
Does anyone nows how to make this replace with the commas only if they are found inside parenthesis?
I've tried this but didn't work:
gen var2 = trim(regexr(Politician,"\((,)+\) *",""))
Thank you very much.
Related Posts with Extracting commas between specific characters
graph bar with error barsHi everyone, I am beginning with STATA and I am creating a graph bar but I can't find how to add er…
Varlist required errorHello everyone, This might seem a very simplistic problem, but I am getting an error "varlist requi…
Combining mlabel margins and mlabel p values in one coefplotDear Statalists, My question is about combining 2 types of mlabels in one coefplot in Stata 15. I …
Predicting individual-level slopes and intercepts after running mixed-effects modelsHi All I'm running two linear spline mixed-effects models (growth curve analysis) looking at MH and…
How to expand yscale range in marginsplot with addplotUsing Stata/SE 16.1 I made two related Figures that should be easily comparable. This means that the…
Subscribe to:
Post Comments (Atom)
0 Response to Extracting commas between specific characters
Post a Comment