We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When some values are tagged NA with labels, write_xpt throws errors
NA
write_xpt
library(dplyr) data_orig <- tibble( var = c("1", "2", "2", "2", "3", "999", "1", "3", "777", NA), ) data_labelled_stata_sas <- data_orig |> mutate( var = case_when( var == 999 ~ haven::tagged_na("d"), var == 777 ~ haven::tagged_na("r"), .default = as.double(var) ) |> labelled::set_value_labels( c( yes = 1, maybe = 2, no = 3, "don't know" = haven::tagged_na("d"), "refused" = haven::tagged_na("r") ) ) |> labelled::set_variable_labels( "var" = "Do you like ice cream?" ) ) haven::write_xpt(data_labelled_stata_sas, "data_labelled_sas.xpt")
#> Error: Failed to insert value [6, 1]: A provided tag value was outside the range of allowed values in the #> specified file format.
Is there a way to make it work?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When some values are tagged
NA
with labels,write_xpt
throws errorsIs there a way to make it work?
The text was updated successfully, but these errors were encountered: