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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 392 views
  • 2 likes
  • 3 in conversation