Title

statastates - Stata module for merging U.S. state identifiers

Syntax

statastates, [abbreviation(string) fips(string) name(string)] nogenerate

Description

statastates is a simple Stata module for adding U.S. state identifiers (abbreviation, FIPS code, and name) that may be missing from your dataset.

statastates is compatible with Stata v12.1+. While it may be compatible with earlier versions, it has not been tested in those environments.

Options

Required: Make sure to include one of the following arguments.

abbreviation(string) Use this option if you would like to merge using the two-letter state abbreviation and to specify the relevant variable name in your master dataset.

fips(string) Use this option if you would like to merge using the one or two-digit state FIPS code and to specify the relevant variable name in your master dataset.

name(string) Use this option if you would like to merge using the full state name and to specify the relevant variable name in your master dataset.

Optional:

nogenerate Use this option if you do not want to mark merge results with the new variable _merge. This option will also limit your dataset to matched observations and unmatched master observations.

Examples

statastates is pretty easy to use. Just run the command and include the relevant option, which is contingent on whether you would like to merge using the two-letter state abbreviation, FIPS code, or name.

For example, if you have the state abbreviations in your dataset under the variable "state" and want to merge state FIPS codes and names using that variable, enter the following:

statastates, abbreviation(state)

If you have the state FIPS codes in your dataset under the variable "state" and want to merge state abbreviations and names using that variable, enter the following:

statastates, fips(state)

Lastly, if you have the state names in your dataset under the variable "state" and want to merge state abbreviations and FIPS codes using that variable, enter the following:

statastates, name(state)

By default, statastates will generate a new variable, _merge, to mark merge results. If you do not want to create this variable, specify nogenerate. This will keep matched observations and unmatched master observations.

statastates, name(state) nogenerate

Author

William L. Schpero

Contact

william.schpero@yale.edu