BookmarkSubscribeRSS Feed
orangekitty
Fluorite | Level 6

Hello!

 

I have a data set with Street, City, State, and ZipCode but some of the data only contain City and State and are missing ZipCode. 

 

I know that the SASHELP.ZIPCODE library contains ZipCode data for City and States.

How would I be able to: 

Take the instances that are missing ZipCode --> Take State and City that are present --> Compare to the SASHELP.ZIPCODE library and then --> Return the ZipCode value stored in SASHELP.ZIPCODE library if the City and State values match the StateCode and (City or Alias_CityN) 

 

Really lost and any guidance is appreciated! 

 

2 REPLIES 2
Reeza
Super User
I think in this case it would be very helpful if you could make an example of your issue, a reproducible example that mimics your situation and you can use to help debug the issues. Show what you have, what you want and what you've tried. You only need to include 5 to 10 records but they should illustrate the different cases you want to consider. Please post data as text, not as images or attachments.

ballardw
Super User

@orangekitty wrote:

Hello!

 

I have a data set with Street, City, State, and ZipCode but some of the data only contain City and State and are missing ZipCode. 

 

I know that the SASHELP.ZIPCODE library contains ZipCode data for City and States.

How would I be able to: 

Take the instances that are missing ZipCode --> Take State and City that are present --> Compare to the SASHELP.ZIPCODE library and then --> Return the ZipCode value stored in SASHELP.ZIPCODE library if the City and State values match the StateCode and (City or Alias_CityN) 

 

Really lost and any guidance is appreciated! 

 


Most cities with population over 10,000 or so are likely to have more than one Zip code. So, are you willing to accept any Zip code in the city?

 

Also some very small towns may not have their own Zip code but receive mail in a nearby town and so may not be in the Zip code data set.

 

For your consideration, you may have some spelling issues for matching values of names as well. If you have names with apostrophes the apostrophe may not be present in the Zip code set. Some common abbreviations may need to be expanded if in your data such as St. Louis would require "Saint Louis" for matching the SAS data.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 764 views
  • 2 likes
  • 3 in conversation