PUMA GEO Codes to State Names

CODAP Forums CODAP Help Forum PUMA GEO Codes to State Names

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6503 Score: 0

    I have a dataset with geo codes for PUMAS (i.e. g0100100) and I know the first two digits after the g represent the state for the PUMA. What I need help with is finding a formula I could use in CODAP to create a new attribute with letter abbreviations for each state from the two digit designations in the PUMA geo codes. I am guessing I need some kind of index that maps the two with a find and replace like feature but I could use some help. Thanks!

    #6505
    Bill Finzer
    Keymaster

    Hi Travis,

    1. Create a new attribute stateCode with the formula:
      subString(full geo codes, 2, 2).
      This extracts (as a number) the code for the state.
    2. Import into your document a dataset that has each state and its code. Let’s say its name is states_with_codes and that it has attributes code and name.
    3. Back in the original dataset create a new attribute stateName with the formula:
      lookupByKey(“states_with_codes”, “name”, “code”, stateCode)
    4. You’ll probably want to Delete Formula (Keeping Values) for both of these new attributes you’ve created.

    You can actually replace step 3 with a join move. Drag the code attribute from your imported dataset on top of stateCode and release. Voilá! You’ve joined the two datasets.

    Hope this helps.

    Bill

    #6506

    It worked! Thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.