countyfips is a simple Stata crosswalk program for adding various county-level identifiers (name, FIPS, Census codes) that may be missing from your dataset. The purpose of this program is to facilitate merging datasets that do not share a common identifier.
countyfips is compatible with Stata version 12.1+. It may be compatible with previous versions, but it has not been tested in those environments.
Github (for Stata v13.1+): Run the following via the Stata command line.
net install countyfips, from(https://raw.github.com/cbgoodman/countyfips/master/) replace
Github (for Stata v12.1+): Download the zipped file of this repository. Unzip on your local computer. Run the following code via the Stata command line replacing with the location of the unzipped repository on your computer.
net install countyfips, from(<local source>) replace
countyfips offers four methods of merging using either county names, five-digit county FIPS codes, the combination of two-digit state FIPS and three-digit county FIPS codes, or the combination of two-digit state Census codes and three-digit county Census codes.
name where county is the name of county requires either
statecode to be specified
. countyfips, name(county) statefips(stfips)
. countyfips, name(county) statecode(stcode)
. countyfips, fips(county)
. countyfips, statefips(stfips) countyfips(cofips)
. countyfips, statecode(stcode) countycode(cocode)
countyfips will generate a new variable,
_merge, to indicate the merged results. If you do not want to create this variable, specify
This will keep matched observations and unmatched master observations.
. countyfips, fips(county) nogenerate
nameoption requires specific formatting of the
namevariable. County names must not include "county" after the name. County names beginning with "Saint" such as Saint Louis must be abbreviated to "St."
- FIPS codes are available for U.S counties, county equivalents, and territories. Census codes are only available for counties or county equivalents (such as independent cities).
- FIPS codes for Virginia independent cities as well as merged county and independent cities (as is the practice for some areas in BEA data) are included. Using
nameoption will require extremely particular formatting. Additionally, only the
statefipsoption will work when merging with
countyfipsuses the more recent FIPS code for Miami-Dade county (12086) rather than the FIPS code for Dade county (12025). The Census state (10) and county (13) codes remain unchanged.
Please report any bugs here.