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
How to interpret predicted probabilities with continious variables in logistic regression?Hello everyone, I've got a question regarding how to interpret continious variables in logistic reg…
Calculating time between specific events in panel dataHello, I have panel data with 1 to 10 events per patid. The eventdate is the date of the stroke and…
extracting several string values from several different variablesHello, i am working with treatment data i have treatment1 treatment2 treatment3 treatmentn variables…
Can I match on a baseline dataset from 2018 (treatment) and 2020 (control)?Dear Statalisters, I am currently writing my thesis on the topic of Multidimensional Empowerment. F…
How to identify all cases with missing observationDear All How can I identify and list all cases with missing observation(denoted by .a) from a data …
Subscribe to:
Post Comments (Atom)
0 Response to Extracting commas between specific characters
Post a Comment