Dear all,
I'm struggeling with removing the numeric part of a string variable that contains both: numeric and non-numeric characters. An example of my data looks like this:
However, what I would like to have is this:
With
I came the closest so far. But this code leaves me with:
Does anyone have a Suggestion on how I could get rid of the numeric part? Or alternatively, how I could extend the regexm condition such that it keeps the parentheses as well as the part after "AA"?
Best
Christian
I'm struggeling with removing the numeric part of a string variable that contains both: numeric and non-numeric characters. An example of my data looks like this:
Code:
. list test in 1/3
+--------------------------------------------+
| test |
|--------------------------------------------|
1. | 555 AA Saarland |
2. | 515 AA Kaiserslautern Pirmasens |
3. | -5 (leer) |
+--------------------------------------------+
Code:
. list test_new in 1/3
+--------------------------------------------+
| test_new |
|--------------------------------------------|
1. | AA Saarland |
2. | AA Kaiserslautern Pirmasens |
3. | (leer) |
+--------------------------------------------+
Code:
gen test_new = regexs(0) if regexm(test, "[a-zA-Z]+")
Code:
. list test_new in 1/3
+--------------------------------------------+
| test_new |
|--------------------------------------------|
1. | AA |
2. | AA |
3. | leer |
+--------------------------------------------+
Best
Christian

Comment