List of Neighboring States (with Stata Code)

An important question has not yet been addressed on this blog: can I get Stata code into a post? Yes I can! What is truly excellent is that the same post also addresses another need: what else can one do to pass the time while trying to fall asleep?

If for that purpose, or otherwise, you need a list that for each U.S. state specifies which other states neighbor (border on, are closest to) it then this post is for you. And it fills a void on the internet. I needed such a list for some analysis I’m doing and couldn’t find one so I made my own.

Since I do my analysis in Stata, the list below is really Stata code that constructs one indicator for each state (call it the “target” state) that has the value one (1) for observations in states neighboring the target state and zero (0) otherwise. So, if you need to do precisely this in Stata too, this is your lucky day. I just saved you 30 minutes of work.

If you don’t read Stata just notice that the capital letters on the left hand side of the equations below identify a state and the ones on the right are its neighbors. Ignore all other characters (and especially those promising to cut deficits without health reform).

I define CA to be the neighbor of HI and WA to be the neighbor of AK. Just interpret “neighbor” as “nearest” and these make sense. Other than these exceptions and the case of states sharing a corner (AZ, CO, NM, UT), which I consider neighbors, a target and its neighboring state must share more than zero miles of border (this is arbitrary but good enough for my needs).

In the list below, “sXXn” is shorthand for “state XX neighbors” where XX is the state’s two letter code. Anyone who finds an error in my list wins one hundred thousand units of The Incidental Economist credit, to be delivered by telepathy into the ledger I keep in an undisclosed location and which can be redeemed for your choice of fanciful prize of whimsy and mirth. (I’m really in a good mood in anticipation of my representative not coming home this weekend and instead doing something substantial and important in DC.)

US map

gen sAKn = inlist(stateab,”WA”)
gen sALn = inlist(stateab,”TN”,”GA”,”FL”,”MS”)
gen sARn = inlist(stateab,”MO”,”TN”,”MS”,”LA”,”TX”,”OK”)
gen sAZn = inlist(stateab,”UT”,”CO”,”NM”,”CA”,”NV”)
gen sCAn = inlist(stateab,”OR”,”NV”,”AZ”,”HI”)
gen sCOn = inlist(stateab,”WY”,”NE”,”KS”,”OK”,”NM”,”AZ”,”UT”)
gen sCTn = inlist(stateab,”MA”,”RI”,”NY”)
gen sDCn = inlist(stateab,”MD”,”VA”)
gen sDEn = inlist(stateab,”PA”,”NJ”,”MD”)
gen sFLn = inlist(stateab,”GA”,”AL”)
gen sGAn = inlist(stateab,”NC”,”SC”,”FL”,”AL”,”TN”)
gen sHIn = inlist(stateab,”CA”)
gen sIAn = inlist(stateab,”MN”,”WI”,”IL”,”MO”,”NE”,”SD”)
gen sIDn = inlist(stateab,”MT”,”WY”,”UT”,”NV”,”OR”,”WA”)
gen sILn = inlist(stateab,”WI”,”IN”,”KY”,”MO”,”IA”)
gen sINn = inlist(stateab,”MI”,”OH”,”KY”,”IL”)
gen sKSn = inlist(stateab,”NE”,”MO”,”OK”,”CO”)
gen sKYn = inlist(stateab,”OH”,”WV”,”VA”,”TN”,”MO”,”IL”,”IN”)
gen sLAn = inlist(stateab,”AR”,”MS”,”TX”)
gen sMAn = inlist(stateab,”NH”,”RI”,”CT”,”NY”,”VT”)
gen sMDn = inlist(stateab,”PA”,”DE”,”DC”,”VA”,”WV”)
gen sMEn = inlist(stateab,”NH”)
gen sMIn = inlist(stateab,”OH”,”IN”,”WI”)
gen sMNn = inlist(stateab,”WI”,”IA”,”SD”,”ND”)
gen sMOn = inlist(stateab,”IA”,”IL”,”KY”,”TN”,”AR”,”OK”,”KS”,”NE”)
gen sMSn = inlist(stateab,”TN”,”AL”,”LA”,”AR”)
gen sMTn = inlist(stateab,”ND”,”SD”,”WY”,”ID”)
gen sNCn = inlist(stateab,”VA”,”SC”,”GA”,”TN”)
gen sNDn = inlist(stateab,”MN”,”SD”,”MT”)
gen sNEn = inlist(stateab,”SD”,”IA”,”MO”,”KS”,”CO”,”WY”)
gen sNHn = inlist(stateab,”ME”,”MA”,”VT”)
gen sNJn = inlist(stateab,”NY”,”DE”,”PA”)
gen sNMn = inlist(stateab,”CO”,”OK”,”TX”,”AZ”,”UT”)
gen sNVn = inlist(stateab,”ID”,”UT”,”AZ”,”CA”,”OR”)
gen sNYn = inlist(stateab,”VT”,”MA”,”CT”,”NJ”,”PA”)
gen sOHn = inlist(stateab,”PA”,”WV”,”KY”,”IN”,”MI”)
gen sOKn = inlist(stateab,”KS”,”MO”,”AR”,”TX”,”NM”,”CO”)
gen sORn = inlist(stateab,”WA”,”ID”,”NV”,”CA”)
gen sPAn = inlist(stateab,”NY”,”NJ”,”DE”,”MD”,”WV”,”OH”)
gen sRIn = inlist(stateab,”MA”,”CT”)
gen sSCn = inlist(stateab,”NC”,”GA”)
gen sSDn = inlist(stateab,”ND”,”MN”,”IA”,”NE”,”WY”,”MT”)
gen sTNn = inlist(stateab,”KY”,”VA”,”NC”,”GA”,”AL”,”MS”,”AR”,”MO”)
gen sTXn = inlist(stateab,”OK”,”AR”,”LA”,”NM”)
gen sUTn = inlist(stateab,”ID”,”WY”,”CO”,”NM”,”AZ”,”NV”)
gen sVAn = inlist(stateab,”MD”,”DC”,”NC”,”TN”,”KY”,”WV”)
gen sVTn = inlist(stateab,”NH”,”MA”,”NY”)
gen sWAn = inlist(stateab,”AK”,”ID”,”OR”)
gen sWIn = inlist(stateab,”MI”,”IL”,”IA”,”MN”)
gen sWVn = inlist(stateab,”PA”,”MD”,”VA”,”KY”,”OH”)
gen sWYn = inlist(stateab,”MT”,”SD”,”NE”,”CO”,”UT”,”ID”)

There. If a blog is not the appropriate place to publish academic work of this form and caliber, I don’t know what is. Void filled.

Hidden information below

Subscribe

Email Address*