Hi All,
I'm looking for help matching postal codes. I have a list of postal codes in one table and a list of postal codes and latitude and longitude in another. I need to match the postal codes by either all 6 or the first instance where 5 (or 4 or 3) characters match.
example:
list of codes
L1G3H8
L1G3J0
L1G3J1
L1G3J2
L1G3J3
list of codes with lat and long
L1G3J1 43.920899 -78.874794
L1G3J2 43.920732 -78.874717
L1G3J3 43.920354 -78.876291
desired result
L1G3H8 43.920899 -78.874794
L1G3J0 43.920899 -78.874794
L1G3J1 43.920899 -78.874794
L1G3J2 43.920732 -78.874717
L1G3J3 43.920354 -78.876291
What do you mean by
the first instance where 5 (or 4 or 3) characters match.
Why "first" match? Shouldn't all matching 5 character codes have an equal chance of being randomly selected?
Start with an exact match on all 6 characters, then with the remaining rows a 5 character match. The problem is that with any matches with less than 6 characters you are not necessarily going to get a unique match. What post code will you choose when there are multiple choices? The first or last sorted value or some other strategy?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.