If you sort a list of Texas counties by county name, the counties will not be in order by county number.
Texas Center for Healthcare Statistics

Every county in the United States has a FIPS code. These standards codes are usful for mapping and joining additional datasets.

Texas state agencies do not bother with these FIPS codes. Instead, each state agency publishes data using their own county codes. The county codes of one state agency may not match other agencies’ county codes. I recently spent a few hours extremely confused by this, because I used the formula published by the Texas Department of State Health Services on data published by the Texas Health and Human Services, resulting in incorrect data.

I understand that imperfect solutions often come about because the success criteria is something that works, not something that meets everyone’s needs in every situation.

And since they work, the additional amount of time needed to make them better often isn’t worth it given all the things that don’t work. For many tasks, that is probably fine - if you know the limitations of your solution and adjust accordingly.

But each Texas state agency using its own subtly different coding system for counties is the type of issue that deserves fixing because it can lead to bigger problems. Because they publish these codes to the public, and people disseminate data without guidance from the original authors. And so it surprises me that rather than settle on a standard set of county codes that could be used across all Texas state agencies, they each implement their own guidance.

How do they assign codes?

The majority sort counties alphabetically by county name and use the row index number as the ID. You’ll see this on the Texas Comptroller codes, and in the data file in question: the Medicaid and CHIP Enrollment by Risk Group by County, Preliminary from the Healthcare Statistics page on the Texas Health and Human Services website (HHS).

Logo for HHS Website

This data file is released at hhs.texas.gov, under the Texas Health and Human Services website.

However, this convenient solution doesn’t give an easy conversion to FIPs codes.

When I found these county codes and wanted to get match them to the FIPs codes to join Census data, I found a page at the Texas Department of State Health Services (DSHS) website dshs.texas.gov that gives a helpful formula.

Logo for DSHS Website

DSHS gives a formula to translate county IDs to FIPs codes:

The county FIPS code can be calculated from the Texas county number: FIPS_code = 48000 + (county_number * 2) - 1.

However, the County IDs published in the HHS Medicaid data file do not match the county numbers on the DSHS conversion table. This is because an alphabetic sort index doesn’t match the order of the IDs:

  • spaces change the order (Ellis after El Paso)
  • prefixes (“Mc..”) are sorted before other “M…” counties

So if I use the DSHS formula on the HHS data, I will get the incorrect FIPs code since the input County ID is not correct. In the published file, Martin county had the county ID of 156, which suggests a FIPS code of 48 + (156 * 2) - 1 = 48311. The FIPS code 48311 actually corresponds with McMullen county.

I made the mistake of thinking that the advice published on the DSHS website applied to the data on the HHS website. From their logos, I thought the DSHS was a sub-office of the HHS.

Since this sorting error only switches a few of the counties, a majority of the data county IDs are correct. As someone not familiar with the data practices of various Texas state agencies, it was only when I normalized enrollment counts against population (from Census data) that I realized some counties had enrollment over 100%.

Intuitively I worked backwards, which cost me a few hours of work - I thought my join must be wrong, or the Census data I pulled, or when I calculated the FIPs codes. I also foolishly checked other state agency data - which only further confused me, because since the other agency did use the alphabetic sort method, the data across both files matched. I also checked the data in the file by county name, which held up, since the county names and counts were always correct!

Correcting this meant pulling the published HHS Healthcare Statistics numbers and joining (based on name) to the DSHS table online to pull the correct ID and FIPs codes.

Overall

Texas state agencies use county IDs that do not align with the federal standard. I am curious as to why this was implemented - it is easy to think that doing the alphabetic sort by name for them was just easier and they didn’t think about the consequences, but perhaps I am being cynical.

Alphabetic Texas County IDs to FIPs Codes

The following table links the Texas County IDs (obtained through the row index from a standard alphabetic sort) to their county FIPs codes.

Alphabetic Sort County IDDSHS NumberCounty NameFIPS Code
11Anderson48001
22Andrews48003
33Angelina48005
44Aransas48007
55Archer48009
66Armstrong48011
77Atascosa48013
88Austin48015
99Bailey48017
1010Bandera48019
1111Bastrop48021
1212Baylor48023
1313Bee48025
1414Bell48027
1515Bexar48029
1616Blanco48031
1717Borden48033
1818Bosque48035
1919Bowie48037
2020Brazoria48039
2121Brazos48041
2222Brewster48043
2323Briscoe48045
2424Brooks48047
2525Brown48049
2626Burleson48051
2727Burnet48053
2828Caldwell48055
2929Calhoun48057
3030Callahan48059
3131Cameron48061
3232Camp48063
3333Carson48065
3434Cass48067
3535Castro48069
3636Chambers48071
3737Cherokee48073
3838Childress48075
3939Clay48077
4040Cochran48079
4141Coke48081
4242Coleman48083
4343Collin48085
4444Collingsworth48087
4545Colorado48089
4646Comal48091
4747Comanche48093
4848Concho48095
4949Cooke48097
5050Coryell48099
5151Cottle48101
5252Crane48103
5353Crockett48105
5454Crosby48107
5555Culberson48109
5656Dallam48111
5757Dallas48113
5858Dawson48115
5959Deaf Smith48117
6060Delta48119
6161Denton48121
6262DeWitt48123
6363Dickens48125
6464Dimmit48127
6565Donley48129
6666Duval48131
6767Eastland48133
6868Ector48135
6969Edwards48137
7071El Paso48141
7170Ellis48139
7272Erath48143
7373Falls48145
7474Fannin48147
7575Fayette48149
7676Fisher48151
7777Floyd48153
7878Foard48155
7979Fort Bend48157
8080Franklin48159
8181Freestone48161
8282Frio48163
8383Gaines48165
8484Galveston48167
8585Garza48169
8686Gillespie48171
8787Glasscock48173
8888Goliad48175
8989Gonzales48177
9090Gray48179
9191Grayson48181
9292Gregg48183
9393Grimes48185
9494Guadalupe48187
9595Hale48189
9696Hall48191
9797Hamilton48193
9898Hansford48195
9999Hardeman48197
100100Hardin48199
101101Harris48201
102102Harrison48203
103103Hartley48205
104104Haskell48207
105105Hays48209
106106Hemphill48211
107107Henderson48213
108108Hidalgo48215
109109Hill48217
110110Hockley48219
111111Hood48221
112112Hopkins48223
113113Houston48225
114114Howard48227
115115Hudspeth48229
116116Hunt48231
117117Hutchinson48233
118118Irion48235
119119Jack48237
120120Jackson48239
121121Jasper48241
122122Jeff Davis48243
123123Jefferson48245
124124Jim Hogg48247
125125Jim Wells48249
126126Johnson48251
127127Jones48253
128128Karnes48255
129129Kaufman48257
130130Kendall48259
131131Kenedy48261
132132Kent48263
133133Kerr48265
134134Kimble48267
135135King48269
136136Kinney48271
137137Kleberg48273
138138Knox48275
139142La Salle48283
140139Lamar48277
141140Lamb48279
142141Lampasas48281
143143Lavaca48285
144144Lee48287
145145Leon48289
146146Liberty48291
147147Limestone48293
148148Lipscomb48295
149149Live Oak48297
150150Llano48299
151151Loving48301
152152Lubbock48303
153153Lynn48305
154157Madison48313
155158Marion48315
156159Martin48317
157160Mason48319
158161Matagorda48321
159162Maverick48323
160154McCulloch48307
161155McLennan48309
162156McMullen48311
163163Medina48325
164164Menard48327
165165Midland48329
166166Milam48331
167167Mills48333
168168Mitchell48335
169169Montague48337
170170Montgomery48339
171171Moore48341
172172Morris48343
173173Motley48345
174174Nacogdoches48347
175175Navarro48349
176176Newton48351
177177Nolan48353
178178Nueces48355
179179Ochiltree48357
180180Oldham48359
181181Orange48361
182182Palo Pinto48363
183183Panola48365
184184Parker48367
185185Parmer48369
186186Pecos48371
187187Polk48373
188188Potter48375
189189Presidio48377
190190Rains48379
191191Randall48381
192192Reagan48383
193193Real48385
194194Red River48387
195195Reeves48389
196196Refugio48391
197197Roberts48393
198198Robertson48395
199199Rockwall48397
200200Runnels48399
201201Rusk48401
202202Sabine48403
203203San Augustine48405
204204San Jacinto48407
205205San Patricio48409
206206San Saba48411
207207Schleicher48413
208208Scurry48415
209209Shackelford48417
210210Shelby48419
211211Sherman48421
212212Smith48423
213213Somervell48425
214214Starr48427
215215Stephens48429
216216Sterling48431
217217Stonewall48433
218218Sutton48435
219219Swisher48437
220220Tarrant48439
221221Taylor48441
222222Terrell48443
223223Terry48445
224224Throckmorton48447
225225Titus48449
226226Tom Green48451
227227Travis48453
228228Trinity48455
229229Tyler48457
230230Upshur48459
231231Upton48461
232232Uvalde48463
233233Val Verde48465
234234Van Zandt48467
235235Victoria48469
236236Walker48471
237237Waller48473
238238Ward48475
239239Washington48477
240240Webb48479
241241Wharton48481
242242Wheeler48483
243243Wichita48485
244244Wilbarger48487
245245Willacy48489
246246Williamson48491
247247Wilson48493
248248Winkler48495
249249Wise48497
250250Wood48499
251251Yoakum48501
252252Young48503
253253Zapata48505
254254Zavala48507

Thanks to TablesGenerator through https://www.tablesgenerator.com/markdown_tables.