Convert one annual Core file into Parquet.
Arguments
- path
Path to one annual NIS Stata (
.dta), SAS (.sas7bdat), or SPSS (.sav) file with a numericYEARcolumn, or one HCUP fixed-widthNIS_<year>_Core.ASCfile from 2012 through 2024.- dir
Existing directory in which to create
NIS_<year>.parquet/.- encoding
Source encoding override passed to haven. The default uses the reader's format-specific encoding. Use
"latin1"for a legacy Stata file known to use Latin-1.
Details
The converter accepts HCUP's fixed-width Core layout for
2012 through 2024 and annual Stata, SAS, or SPSS files. For those three
formats, supply a numeric YEAR column. All rows must have the same
year. Populated code slots must agree with the coding era. The 2015
ASCII Core file has separate diagnosis and procedure files that this
function does not join.
Conversion stops on malformed text or invalid codes. Use an existing output directory. The converter creates one new annual directory and leaves any existing annual directory intact.
See also
Other data-access:
nis_example(),
nis_join_companion(),
nis_label(),
nis_open(),
nis_vars_design()
Examples
if (requireNamespace("haven", quietly = TRUE)) {
dir <- tempfile()
dir.create(dir)
path <- file.path(dir, "NIS_2020.dta")
nis <- nis_open(nis_example(2020)) |>
dplyr::select(YEAR, KEY_NIS, I10_DX1) |>
dplyr::collect()
haven::write_dta(nis, path)
nis_convert(path, dir)
nis_open(dir, check_release = FALSE) |>
dplyr::count(YEAR) |>
dplyr::collect()
}
#> # A tibble: 1 × 2
#> YEAR n
#> <int> <dbl>
#> 1 2020 96