Hello, I have over 17000 observations in a dataset and one of the Variables is postal_code. I need to create a dataset which has only the correct postal codes i.e K2C0J8. the postal code should be six digits as in the example above, have no spaces, no special characters and the 2nd, 4th and the 6th spaces should be numbers and the first, third and fifth places alphabets. here is my code so far: data CORRECTPOSTAL NOPOSTAL; set Y; if length(compress(postal_code,"-/+~! )( "))=6 and PRXMATCH(PRXPARSE("/\w\d\w\d\w\d/i"),compress(postal_code,"- ")) then do; POSTAL=compress(postal_code,"-/+~! )( "); output CORRECTPOSTAL; end; else output NOPOSTAL; run; this does the job alright but misses out on some observations and I dont know why. Thanks, M
... View more