Dear all,
I have to "cut a string into pieces". The "seperator" being a upper case letter.
e.g. var name "AbrahamAndyGregor" should be divided in var name1 "Abraham" var name2 "Andy" and var name3 "Gregor".
There are about 180 "names" combined in different ways. I do have a list of names.
What I tried was to set the first letter to lower case -->
gen name1=(lower(substr(name, 1, 1))) + (substr(name, 2, .)) ---> name will be abrahamAndyGregor.
Thus I could extract the first name ...
gen name1 = regexs(0) if regexm(name, "[a-zäöüß ]+")
(Those freaky letters äöüß are just because they appear in the names - also blanks).
Then I tried to get the second name - and failed ;-)!
I tried different combinations like ...
gen name2 = regexs(1) if regexm(name, "(([a-zäöüß ]+)([A-ZÄÖÜ][a-zäöüß ]+))")
gen name2 = regexs(0) if regexm(name, "([A-ZÄÖÜ][a-zäöüß ]+)")
Asking the forum kindy for help - best regards,
Lynde
Related Posts with Seperating a string into substrings (by upper case letters)
Jackknife for xtpcseHi, I am trying to conduct a Jackknife estimation. The following command is able to be executed, e…
xtptqtest error: ue: At least one panel is too shortDear Community, In order to test for auto correlation in the error term of my dynamic panel regress…
Error Correction Model (ECM) for panel dataDear all, I want to use an ECM model to estimate the short-term elasticity. I have a panel data and…
Brant test assumptions Hello community, I wanted to ask about the assumption of proportional odds and the Brant test. i ha…
Differences between value-weighted portfolio regression and portfolio regression with aweight based on MCAPDear Statalists, I have done a quintile portfolio analysis and there is a declining pattern of equa…
Subscribe to:
Post Comments (Atom)
0 Response to Seperating a string into substrings (by upper case letters)
Post a Comment