# \donttest{
if (requireNamespace("haven", quietly = TRUE)) {
# Roundtrip through a temporary .dta file (with your own data,
# simply pass its path instead)
tmp <- tempfile(fileext = ".dta")
write_stata(survey_data, tmp)
data <- read_stata(tmp)
# Read with SPSS-style missing codes tagged as distinct NA types
data <- read_stata(tmp, tag_na = c(-9, -8))
# frequency() shows each missing type separately
data |> frequency(income)
unlink(tmp)
}
# }
Run the code above in your browser using DataLab