var("IND", case_selections=?)

I am trying to create an extract subset to industry and occupation codes:

  ipums_acs_extract <- ipumsr::define_extract_usa(
    description = "IND_OCC",
    samples = "us2021c",
    variables = list(
                  var_spec("IND", case_selections=7870),
                  var_spec("OCC", case_selections=2205)),
    data_format = "csv",
    data_structure = "rectangular",
    rectangular_on = "P"
  )

With integers in case_selections, I am getting

! Invalid `var_spec` specification:
x `case_selections` must be of type `character`, not `integer`.

With characters in case_selections, I am getting

! API request failed with status 400.
x Invalid general case selection of 2205 for variable OCC
x Invalid general case selection of 7870 for variable IND

Trying case_selection_type="detailed" fails with

! API request failed with status 400.
x Detailed case selection made but detailed variable not found for IND.
x Detailed case selection made but detailed variable not found for OCC.

I understand that these are variables with hundreds of categories. But something fell between the cracks of the API vs. ipumsr. These are valid codes as I can run the extract without them and filter() just fine.

> packageVersion("ipumsr")
[1] ‘0.7.0’

Hi Stas,

I’m sorry to hear that you ran into this difficulty using the API. The source of this issue is that not all variables, for example OCC and IND, are eligible for case selection in our extract system. The IPUMS USA website automatically omits variables from the case selection option on the extract options stage if they are not eligible, but we have not yet implemented any similar mechanism to prevent users from trying to run case selections on these variables using the API. I have shared your post with our API working group who indicated that they would work on adding a more descriptive error code for this case.

I see. In the meantime, the error message should probably say something to the effect of “case_selection() is not feasible with OCC variable”.