text: Hello,
  I have a file with about 20 mio. cases, there is a variable: street
  in most cases the street has the form: Text housenumber: e.g. Marburger Strasse 8 , but there are cases with this format : Text digits Text digits or Digit Text digits , e.g. Strasse des 3. Oktober 120, or 55er Str. 30
  how can I pick up all those cases with Text digits Text digits or Digit Text digits ?
  many thanks!
  Answer by jkpeck (5870) | Dec 07, 2017 at 12:49 PM
  SPSS does not have a built-in regular expression function, but you can do this. It might be slow with a huge file. If you have a large number of variables, it might be worth splitting out just this street variable and merging the result. I assumed that all you want is an indicator for the cases that have multiple numeric fields. You could alterntively write a complicated loop in standard Statistics syntax.
  begin program. import re def multdigits(s): return len(re.findall(r"\d+", s)) > 1 end program. spssinc trans result = multiple /formula multdigits(street).
  Answer by jkpeck (5870) | Dec 08, 2017 at 01:52 PM
  You can start on this with the code below, which generates a variable for each numeric regardless of whether it contains a single / or -. I allowed for three numbers, but you can allow for more by listing more result variables if needed. The results are strings of length up to 5, but you can change that, too.
  Then, if the second output field is blank, there was only one number. However, in the case with a separator I left the result field with the combined digits / or - digits, because if I separated them into two fields, you could not distinguish between 11-13 and separate 11 and 13 fields.
  Here is the code.
  begin program. import re def multdigits(s): return re.findall(r"\d+[/-]*\d*", s) end program. spssinc trans result = multiple1 multiple2 multiple3 type=5 /formula multdigits(street).
  Answer by redrose888 (138) | Dec 08, 2017 at 09:28 AM
  Hello John, thank you very much! it works fine! only I have still 2 questions:
  if street is: Marburger Straße 11-13 or 11/13, multiple is 1 too? in this case multiple should be 0 , how can I to this?
  if multiple is 1, how can I separate street in order to create 2 variables : streetname and housenumber, e.g. if street is Strasse des 13. Januar 8, streetname should be Straße des 13. Januar, and housenumber should be 8
  thanks!
  regards
  Answer by redrose888 (138) | Dec 11, 2017 at 09:05 AM
  Hello John,
  thank you very much for your explanation! maybe I haven't explained my problem very clearly. if the housenumber has the form digits-digits or digits/digits with your program it works fine.
  but I have such streetname: Heiligkreuzweg 118b-120, in this case streename should be Heiligkreuzweg, and housenumber 118b-120, or streetname : Straße des 15. Oktober 16 a, in this case streetname should be Straße des 15. Oktober, and housnumber 16 a. Or streetname Rovenkampstr. 17 u. 34, in this case streetname should be Rovenkampstr., and housenumber 17 u. 34, how can I automate this process?
  see screenshot, multiple 2 and multiple 3 shoud be empty
  thank you very much!
  regards,
  [1]: /answers/storage/temp/19056-screenshot.png
  Answer by jkpeck (5870) | Dec 11, 2017 at 09:45 AM
  I don't understand what rule should be applied for some of these cases. With Straße des 15. Oktober 16 a, how could I identify the parts? The regular expression I posted picks out numeric or almost numeric parts, but 16 a does not fit that pattern.
  Answer by redrose888 (138) | Dec 11, 2017 at 10:17 AM
  hello John,
  the rule is: the house number should equal to the substring from the beginning of the second digit , with Straße des 15. Oktober 16 a, the house number is 16 a, but except if 2 digits parts are connected with - or / , with Jahnstr. 9a-13, the house number is 9a-13.
  regards
  Answer by jkpeck (5870) | Dec 12, 2017 at 03:18 PM
  Ok. Let's see if this gets it. It find the last digit sequence in the string, allowing for / or - in it and takes that through the end of the string as the number. The part before that is the street name.
  Answer by redrose888 (138) | Dec 19, 2017 at 10:27 AM
  no unfortunately not :-( I got warnings:
  Function returned too many values. Number expected: 3
  You can list more variables under result, but what input gave you that error message?
  Answer by redrose888 (138) | Dec 20, 2017 at 02:54 AM
  Hello Jon, this is my syntax: get file = "C:\temp\myfile.sav" .
  begin program.
  import re
  def multdigits(s):
  return re.findall(r"\d+[/-]\d", s)
  end program.
  spssinc trans result = multiple1 multiple2 multiple3 type=5
  /formula multdigits(street).
  only with first row multiple1 multiple2 multiple3 not missing, see attached screenshot
  Answer by jkpeck (5870) | Dec 20, 2017 at 05:26 PM
  The second case violates the patterns you described, but you are also not using the updated code I posted above in strassesps.txt. Attached is a version that allows for 0 or more spaces around the / and - characters.
  133 people are following this question.
  How to create new variable from subtraction of 2 other variables IF condition met 12 Answers
  Workaround for UPDATE command when master file contains duplicate values in key variables?, 1 Answer
  How to create an overview of R-squared values in SPSS? 2 Answers
  May someone help me with a question about syntax in Conjoint tool in SPSS 2 Answers
  I am a student and my temporary pass has expired. 1 Answer