Skip to content

Derive PUMS recode_years from pums_variables (remove hard-coding)#636

Merged
walkerke merged 1 commit into
walkerke:masterfrom
ashleyasmus:derive-recode-vars
Mar 21, 2026
Merged

Derive PUMS recode_years from pums_variables (remove hard-coding)#636
walkerke merged 1 commit into
walkerke:masterfrom
ashleyasmus:derive-recode-vars

Conversation

@ashleyasmus

Copy link
Copy Markdown
Contributor

What this does

Closes #634

load_data.R currently hard-codes the year range used to determine whether PUMS recoding is supported (via recode_years <- ...). This PR derives the supported years directly from the packaged pums_variables dataset (scoped to the requested survey), so adding new PUMS dictionaries doesn’t require updating code in load_data.R.

No intended behavior changes beyond removing the manual maintenance step.

Why

pums_variables already contains the authoritative list of survey/year combinations with dictionaries (and thus recode support). Using it eliminates the need to update recode_years annually.

Tests I ran

  • 2023 acs1 recode works (labels returned):
get_pums(state = "Vermont", variables = c("AGEP","SEX"), year = 2023, survey = "acs1", recode = TRUE)

Result includes STATE_label and SEX_label columns.

  • 2024 acs1 currently does not recode on main (expected until dictionary update):
get_pums(state = "Vermont", variables = c("AGEP","SEX"), year = 2024, survey = "acs1", recode = TRUE)

Result shows the current message:

Recoding is currently supported for 2017 - 2023 data. Returning original data only.

(With this PR, the supported-year check is no longer hard-coded and will automatically reflect the years present in pums_variables once 2024 is added.)

Notes

@walkerke walkerke merged commit e2b7e0f into walkerke:master Mar 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Derive recode_years from pums_variables instead of hard-coding

2 participants