Downloads and parses a CDC linked birth/infant death cohort zip file, which contains two fixed-width files sharing the same record layout: the denominator (all births) and the numerator (linked infant death records only).

load_data_birth_cohort(url, meta)

Arguments

url

Character. URL to the CDC zip file containing the cohort data.

meta

A tibble of field definitions (start, end, name, type, codes) used to parse both files. Both files share the same fixed-width layout, with death-related fields (positions 194+) left blank in the denominator for surviving infants.

Value

A named list with two elements:

denominator

All birth records for the cohort year, including both surviving infants and those who died in infancy. Use this as the population base for rate calculations.

numerator

Linked infant death records only — a subset of the denominator where a matching death certificate was found. Use this to count infant deaths.

Examples

url <- "https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/DVS/cohortlinkedus/LinkCO83.zip"
data <- load_data_birth_cohort(url, data_birth_cohort_1983)
#> Error in httr2::req_perform(httr2::req_progress(httr2::request(url)),     path = temp): Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_disk()`:
#> ! Timeout was reached [ftp.cdc.gov]:
#> Connection timed out after 10002 milliseconds
decode_preview(data$denominator, data_birth_cohort_1983)
#> Error in data$denominator: object of type 'closure' is not subsettable
decode_preview(data$numerator, data_birth_cohort_1983)
#> Error in data$numerator: object of type 'closure' is not subsettable