{
  "id": "1999-june-fips-fixes",
  "slug": "1999-june-fips-fixes",
  "url": "https://dwillis.github.io/uplink/article/1999-june-fips-fixes.html",
  "year": 1999,
  "month": "June",
  "monthNum": 6,
  "headline": "FIPS fixes",
  "kicker": "TECH TIP",
  "author_name": "Jeff South",
  "author_title": "",
  "affiliation": "Virginia Commonwealth University",
  "summary": "FIPS codes are standardized federal identification numbers for geographic areas, but their inconsistent storage formats across government databases—sometimes numeric, sometimes character, with or without leading zeroes—creates significant challenges when trying to merge datasets in data analysis tools.",
  "keywords": [
    "FIPS",
    "databases",
    "standardization"
  ],
  "topics": [
    "Data & Databases",
    "Investigative Methods",
    "Technology"
  ],
  "technologies": [
    "Access",
    "FoxPro"
  ],
  "full_text": "To you, it's Texas. But to the Census Bureau, it's \"48.\" You say New York's capital is Albany. Data heads call it \"3601000.\" The Seattle Seahawks' stadium is in King County, Wash. Geo-geeks say the Kingdome is in \"53033.\" Welcome to the digit-laden world FIPS codes - the numbers the federal government uses for every state, county, city and metropolitan area. These codes are not ony shorter, but they are also more precise: After all, is that South Texas county spelled La Salle, LaSalle or Lasalle? But FIPS codes can pose problems, too. Is the code for Alaska \"02\" or just \"2\"? Is California \"06\" or \"6\" - and within that state, is Orange County \"059\" or simply \"59\"? Moreover, what's the data type for these codes - numeric or character?\n\nThose are important questions if you're using Access, FoxPro and other tools for doing data analysis.\n\nIf one table has its FIPS codes as numeric fields and another table's codes are character strings, you can't automatically join the tables. FIPS codes - the acronym stands for Federal Information Processing Standards- are used in datasets on a variety of subjects, from population and home loans to pollution and traffic accidents.\n\nBut they're stored in an annoying array of ways by the Census Bureau, the IRS and other government agencies.\n\nIf one table has its FIPS codes as numeric fields and another table's codes are character strings, you can't automatically join the tables.\n\nSometimes FIPS codes are numbers; other times they're text. Even when the codes are character strings, they can have different formats, such as \"007\" (leading zeroes) or \"7\" (a number followed by spaces or blanks) or \"7\" (spaces before the number). Here are some tips on dealing with variations in FIPS code fields. One tip is a workaround: how to join on the fly tables that have their codes stored in different ways. The other tip is a fix: how to add permanent fields that present FIPS codes the right way.\n\nWhat is the right way?\n\nFIPS codes should be character fields. State-code fields should be two characters wide; county-code fields, three; metropolitan areas, four; cities, county divisions and other populated places, five.\n\nThe codes should have leading zeroes, so that Alabama is \"01,\" Alaska \"02,\" Arizona \"04\"\n\nThe codes are stored in an annoying array of ways by the Census Bureau, the IRS and other government agencies.\n\n(Curiously, there is no \"03\" among the state codes, and the codes for counties are all odd numbers.)\n\nBut what do you do when a government agency provides a table with FIPS codes stored differently? I encountered this recently when I got 1996-97 county-to-county migration data from the IRS: All the FIPS codes were numeric (California was \"6,\" and Los Angeles County was \"37\"). In years past, the codes were all character fields (California was \"06,\" and Los Angeles County was \"037\").\n\nTo join the new and old data - that is, to make the records match - I had to persuade FoxPro to consider the number \"6\" the same as the character string \"06\" and the number \"37\" the same as the character string \"037.\"\n\nThe workaround: the VAL() function. VAL() converts a character string into a numeric value. In the migration case, I wanted to match my FIPS-as-text fields (st_txt, cnty_txt) in my old data with my FIPS-as-numeric fields (st_num, cnty_num) in my new data. So I used this as my join condition: where new.st_num = val(old.st_txt) and new.cnty_num = val(old.cnty_txt) That says: Match the numeric FIPS code with the numeric value of the character FIPS codes. The VAL() function works in Access as well as in FoxPro. VAL() also can be used to join two text fields that have different FIPS code formats. A Virginia state agency once gave me data in which the county FIPS codes were character strings but without leading zeroes.\n\nOften you'll want to permanently change how FIPS codes are stored in your data. For instance, it will be faster and easier to join tables if your codes are consistent. Moreover, your codes must use the same format if you want to append records from one table into another table.\n\nI wanted to join this with Census Bureau data in which the county codes did have leading zeroes. So my join condition was: where val(table1.fips) = val(table2.fips) That way, \"1\" in the state's FIPS code field matched \"001\" in the Census Bureau's field, \"3\" matched \"003,\" and so on.\n\nThe fix: STR, LTRIM and PADL functions.\n\nOften I want to permanently change how FIPS codes are stored in your data. For instance, it will be faster and easier to join tables if your codes are consistent. Moreover, your codes must use the same format if you want to append records from one table into another table.\n\nLet's say you have a table in which the state FIPS code (st_num) and county FIPS code (cnty_num) fields are both numeric. In FoxPro's Table Designer, insert two character fields: st_fips, with a width of 2; and cnty_fips, with a width of 3. Then run this command:\n\nreplace all st_fips with; padl(ltrim(str(st_num)),2,'0') This takes a numeric \"1\" in the st_num field and turns it into the character string \"01\" in the st_fips field. Here's how the command works, starting from the middle of the second line:\n\nstr(st_num) means convert the number into a character string.\nltrim(str(st_num)) means trim all the blanks from the left side of this character string.\npadl(ltrim(str(st_num)),2,'0') means pad the string with zeroes so it fills up a width of 2 characters.\n\nYou can change the numeric cnty_num field into cnty_fips, a character field with leading zeroes, the same way: replace all cnty_fips with; padl(ltrim(str(cnty_num)),3,'0') Use a similar command to change a text field without leading zeroes (cnty_no0) into one with leading zeroes (cnty_fips): replace all cnty_fips with; padl(alltrim(cnty_no0),3,'0') This says: Take the cnty_no0 field; trim all the blanks at the beginning and end; then pad it with zeroes to a width of three characters.\n\nConversions in Access\n\nAccess does not support PADL, but it has an even easier function for converting the data. If your county FIPS codes are in a numeric field (cnty_num) and you want them in a text field with leading zeroes (cnty_fips), update the cnty_fips field to: Format(cnty_num, \"000\")\n\nThe same function will convert a text field without leading zeroes into one with leading zeroes.\n\nJeff South can be reached by e-mail at jcsouth@vcu.edu.",
  "provenance": {
    "extracted_by": "anthropic/claude-sonnet-4-6",
    "extracted_at": "2026-07-05",
    "verified": true
  },
  "similar": [
    {
      "slug": "1996-may-growing-collection-of-federal-databases-from-the-nicar-library",
      "score": 0.11
    },
    {
      "slug": "1996-november-california-dreaming",
      "score": 0.101
    },
    {
      "slug": "1997-march-growing-collection-of-federal-databases",
      "score": 0.101
    },
    {
      "slug": "1995-february-from-the-nicar-library",
      "score": 0.098
    },
    {
      "slug": "1997-may-from-the-nicar-library",
      "score": 0.095
    }
  ],
  "html_url": "https://dwillis.github.io/uplink/article/1999-june-fips-fixes.html",
  "json_url": "https://dwillis.github.io/uplink/article/1999-june-fips-fixes.json"
}