Some test data:
data list free /address(a20).
begin data.
abc12345xyz
abc12345-6789zzz
23 x street, 12345
end data.
*pattern matching function.
begin program.
import re
def find(x):
return re.findall(r"\d{4,5}", x) #this line must be indented
end program.
* command to drive all this.
spssinc trans result = fivedigit fourdigit type=5
/formula find(address).
This command looks for numeric strings of length either 5 or 4 and returns two length 5 string variables containing 0, 1, or 2 values. The length restriction provides some incomplete protection from street numbers. The command is designed to fail if it finds more than two matching patterns.
HTH,
Jon Peck