As the heading suggests I am trying to create another column containing just the postcode. I am new to SAS and am really struggling. After reading various threads I think i need to use the SUBSTR function but keep ending up with a blank column.
The only thing I have managed to do is REVERSE the line so the postcode is at the start.
What is the exact format of your INPUT-side and OUTPUT-side (desired) data string?
Consider that the SAS FIND function does permit searching from the end of a character variable, when using a negative third-argument, which is somewhat easier than having to go through the REVERSE gyrations multiple times.
google for postcode and perl regular expression
That should help you locate a postcode within an address, if it is present.
Alternatively, if you can assume postcode is the last one or two words, try
length postcode $11 ;
postcode= scan( address, -1) ;
if length( postcode ) < 5 then
postcode= scan( address, -2) !!' '!! scan( address, -1) ;
Message was edited by: Peter.C