If REC is consistently 3 "Words" with or without the comma then this should work...

s REC="MILFORD OH 12345"

s REC=$tr(REC," ",",")

s CTY=$p(REC,","),STA=$p(REC,",",2),ZIP=$p(REC,",",3)

sticking with your original plan of using $zstrip you could also do this:

s ZIP=$zstrip(REC,"*E'N")      ; Strips Everything (*E), Except Numeric ('N) but this is a bit dodgy as if there's any other number in the string it will appear in the result

so you could try this: 

s REC="A B C,12345"

s REC=$tr(REC," ",",")     ; Translates all Spaces to commas

f x=1:1:$l(REC,",") s Bit=$p(REC,",",x) I Bit?.N s ZIP=Bit      ; This presumes that only one piece of the string is numeric and therefore that's your Zip code. (if there was more than one piece with numerics then it will use the last one) You could be more specific with the pattern match and specify it's ?1.5N (i.e. 1 to 5 Numerics)

Keith has no followers yet.
Keith has not followed anybody yet.
Global Masters badges: