BookmarkSubscribeRSS Feed
AshPatel
Fluorite | Level 6

The solution (Shortest Distance Match) that was provided earlier this week worked fine, however; I have been asked to modify the criteria as below.  I tried modifying the data step but unable to get the expected output.  I can take dividual Miles_Rank one at a time in a separate data step but in our actual data file, we have 10 unique Miles_Ranks (1 to10) for each ZIP.  I believe, there must be a way to have the Miles Ranks logic build in one or two data steps.  I am attaching revised raw data (have1 and have2) and also included expected output sheet.  Sorry, but I am posting this again.  Once again thank you so much!

 

1. Match on zip, city and state (have1 and have2)

2. Want1 all records from have1 with ClientNo where there is a match based on the shortest distance (Miles_Rank)

3. Also, Want2 a list of records from have1 where there is no match

5 REPLIES 5
PhilC
Rhodochrosite | Level 12

your states and zip data appear be corrupted

AshPatel
Fluorite | Level 6

have1

ZIPClientNoCityState
14201A95572Cedar GroveTA
14204A91374Cedar GroveNH
14206A71649BristolKA
14207A63397BuffaloMI
14208A06957Cedar GroveNJ
14209A58062Cedar GroveID
14210A43865BristolIL
14211A06391BristolHA
14212A54498Cedar GroveNC
14213A09533BuffaloUT
14213A09534BuffaloUT
14214A31165BuffaloDC
14215A52498BuffaloNY
14216A77384BuffaloCL
14220A73552BuffaloOH
14220A73553BuffaloOH
14220A73554BuffaloOH
14222A66949BristolSC
14222A66950BristolSC
14222A66951BristolSC
14222A66952BristolSC
14222A66953BristolSC
14222A66954BristolSC
14222A66955BristolSC

 

have2

ZIPMiles_RankDistance_MilesCityState
1420111.1Cedar GroveTA
1420125.3SloanNY
1420139.3AmherstCL
14201415.5BuffaloMI
14201530.1Mo TownNJ
1420410.3Cedar GroveHA
1420410.3BlasdellCL
1420421.5Cedar GroveHA
14204412BlasdellTA
14204515Cedar GroveHA
1421111.1BuffaloMI
1421125.3Mo TownNJ
1421139.3BristolHA
14211415.5AmherstCL
14211530.1Cedar GroveHA
1421310.4BuffaloMI
1421321.5BuffaloUT
1421338BlasdellCL
14213412BuffaloNJ
14213515BlasdellTA
1421410.2BuffaloDC
1421420.4BuffaloDC
1421431.5BuffaloDC
1421448BuffaloDC
14214515BuffaloDC
1421511.2SloanCO
1421522AmherstAL
1421532.5BuffaloNJ
1421546BuffaloNY
14215510KenmoreDE
1421612CheektowagaAR
1421627.2Great HillGE
1421638.8BuffaloNJ
14216414.2Fort ErieXX
14216521.6BuffaloCL
1422013BuffaloWY
1422024.6MiltonNE
1422038MiltonWA
14220414.9BuffaloOH
14220526.2MiltonTE
1422213BristolSC
1422224.6BristolSC
1422238BristolSC
AshPatel
Fluorite | Level 6
Hi Phil, I have reloaded and pasted have1 and have2 again..Please let me know if stil issue with the data
PhilC
Rhodochrosite | Level 12

My remark is two fold, that, for one, the data does not conform with USPS State Abbreviations. Secondly, The zip codes should map many zips to one State, which is not true for your data.  I'm afraid, Code developed on this example data may be misleadingly incorrect when applied to validated address data.

AshPatel
Fluorite | Level 6
Thanks Phil. These are fake data. Any help would be greatly appreciated.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1673 views
  • 0 likes
  • 2 in conversation