I have a dataset downloaded from the IRS reporting AGI by ZIP code (link: irs.gov). However, I'm interested in tying each ZIP code to statistical areas (whether it's [a] primary statistical area, [b] combined statistical area, [c] core-based statistical area, [d] metropolitan statistical area, or [e] micropolitan statistical area). Having all of them in one dataset would be ideal, but I'd settle for just CBSA.

I found a great "crosswalk" dataset on the HUDUser website (link: huduser.gov) that does exactly this--connects ZIP code to CBSA. I merged the two files in SAS on ZIP code and voila, most of my problems were solved. But I realized that there were some blaring issues with the merged dataset; for instance, Los Angeles was characterized by different CBSA codes in each file, amongst other errors. I went back to the download sites (both the AGI by ZIP code dataset from the IRS as well as the HUDUser ZIP code to CBSA dataset) and noticed that they were different dates--2014 and 2016Q3 (HUDUser datasets are updated quarterly), respectively. Of course, this could have been the issue, so I tried a date that was closer to 2014 (2013Q4, which was updated 2013-12-22). Fewer errors this time, but still many errors.

Can anyone weigh in on this? How can I ensure that there is no mis-match between CBSA coding on my IRS dataset and my HUDUser dataset? Or, is there another "long" dataset that contains all statistical areas by ZIP code, where each valid ZIP code is a row in the dataset?

3 Answers 3


I think that you can get what you want from two resources:

  1. The R package noncensus contains a data set called zip_codes that lists the following features for each zip code:
    • zip. U.S. ZIP (postal) code
    • city. ZIP code’s city
    • state. ZIP code’s state
    • latitude. ZIP code’s latitude
    • longitude. ZIP code’s longitude
    • fips. County FIPS Code

So you can get zip code to FIPS. This same package also maps counties to FIPS codes.

  1. The National Bureau of Economic Research provides a downloadable CBSA to FIPS crosswalk. So you should be able to use that to go Zip-to-FIPS-to-CBSA.

The LEHD program of the Census Bureau publishes crosswalks which map every Census Block to a number of other geography types, including ZCTA and CBSA.

You could download one of these crosswalks, filter out just the columns for ZCTA and CBSA, and then take the unique rows -- then for each ZCTA, you would see which CBSA it is in. Note, however, that a few ZCTAs are in more than one CBSA (97759 is in three!) and not all ZCTAs are in any CBSA (the crosswalk uses values of 99999 to indicate "not in a ZCTA" and "not in a CBSA" both).

The crosswalks can be found in https://lehd.ces.census.gov/data/lodes/LODES7/ Look in any given directory for the file named xx_xwalk.csv.gz where xx is the directory name -- the lowercase two-letter state postal code, or equivalent.

There are directories for each of the 50 states, plus Washington, DC, Puerto Rico, and the Virgin Islands. There's also a directory for us which is the equivalent of retrieving all of the other files and stacking them.

In addition to ZCTA and CBSA, the same basic method could be used to identify containment/overlap relationship for any of the included geographies, which include state, county, place (city), congressional district, state legislative districts, school districts -- see the technical docs for the full list.



This has what you need. CBSA to Zip Code mapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.