statefips: State - FIPS code

Description
statefips is the FIPS code for the state of residence of the household. See also statecensus.
Availability
| Sample |
Years |
| Basic |
1978 - present |
| ORG |
1979 - present |
Values
| Value |
Label |
| 1 |
AL |
| 2 |
AK |
| 4 |
AZ |
| 5 |
AR |
| 6 |
CA |
| 8 |
CO |
| 9 |
CT |
| 10 |
DE |
| 11 |
DC |
| 12 |
FL |
| 13 |
GA |
| 15 |
HI |
| 16 |
ID |
| 17 |
IL |
| 18 |
IN |
| 19 |
IA |
| 20 |
KS |
| 21 |
KY |
| 22 |
LA |
| 23 |
ME |
| 24 |
MD |
| 25 |
MA |
| 26 |
MI |
| 27 |
MN |
| 28 |
MS |
| 29 |
MO |
| 30 |
MT |
| 31 |
NE |
| 32 |
NV |
| 33 |
NH |
| 34 |
NJ |
| 35 |
NM |
| 36 |
NY |
| 37 |
NC |
| 38 |
ND |
| 39 |
OH |
| 40 |
OK |
| 41 |
OR |
| 42 |
PA |
| 44 |
RI |
| 45 |
SC |
| 46 |
SD |
| 47 |
TN |
| 48 |
TX |
| 49 |
UT |
| 50 |
VT |
| 51 |
VA |
| 53 |
WA |
| 54 |
WV |
| 55 |
WI |
| 56 |
WY |
Code
Variable creation
********************************************************************************
* statefips
********************************************************************************
gen byte statefips = .
if $marchcps == 1 {
if tm(1962m1) <= $date & $date <= tm(2000m12) {
* to do: identify correct state codes for marchcps
* sometimes tricky in early years
cap drop region
merge m:1 statefips using $stategeocodes, keep(1) nogenerate
}
if tm(2001m1) <= $date {
replace statefips = gestfips
* we want the missing values and the full value labels, so do the following merge
merge m:1 statefips using $stategeocodes, assert(3) nogenerate
cap rename hg_reg gereg
assert region == gereg
* ridiculous hack to pull in value labels for statefips
* which are not merged above
drop statefips
rename statefips_alt statefips
}
}
if $monthlycps == 1 | $maycps == 1 {
* some codes in 1976 do not match Unicon documentation
* for now, ensure missing codes for 1976-1977
if tm(1973m1) <= $date & $date <= tm(1977m12) {
drop region
* even though all state (and other geographic) codes will be missing
* we want the missing values and the full value labels, so do the following merge
merge m:1 statefips using $stategeocodes, nogenerate keep(1)
* ridiculous hack to pull in value labels for statefips
* which are not merged above
drop statefips
rename statefips_alt statefips
}
if tm(1978m1) <= $date & $date <= tm(1993m12) {
drop region statefips
rename state statecensus
merge m:1 statecensus using $stategeocodes
* deal with invalid state codes
* invalid state census code = 3 in 1985m4
if $date == tm(1985m4) {
assert _merge == 3 if statecensus != 3
replace statecensus = . if statecensus == 3
}
else assert _merge == 3
drop _merge
if $date >= tm(1989m1) assert statefips == stfips
* ridiculous hack to pull in value labels for statecensus
* which are not merged above
drop statecensus
rename statecensus_alt statecensus
}
if tm(1994m1) <= $date {
replace statefips = gestfips
merge m:1 statefips using $stategeocodes, assert(3) nogenerate
if $date <= tm(2013m12) assert statecensus == gestcen
assert region == gereg
* ridiculous hack to pull in value labels for statefips
* which are not merged above
drop statefips
rename statefips_alt statefips
}
}
lab var statefips "State - FIPS code"
notes statefips: 1978-1993, derived from Unicon state census code: state
notes statefips: 1994-present, CPS: gestfips
Figure creation
sum year
keep if year == r(max)
gegen tag = tag(statefips)
keep if tag == 1
keep statefips tag
decode statefips, gen(stateabb)
tostring statefips, gen(statefipsstring)
gen labelvar = stateabb + " - " + statefipsstring
maptile tag, geo(statehex) geoid(statefips) labelhex(labelvar) ///
twopt(graphregion(color(white)) ///
plotregion(color(white)) ///
legend(off))
graph export ${variableimages}statefips_titleimage.svg, replace