datasus provides catalog-driven interfaces to the tables
published through TABNET. The main workflow is:
datasus_catalogo();datasus_opcoes();Network examples are not evaluated when this vignette is built because the availability and response time of DATASUS are outside the package’s control.
The local catalog can be searched without contacting DATASUS:
datasus_catalogo()
datasus_catalogo("mortalidade")
datasus_catalogo("cnes")
datasus_catalogo("sinan")The result identifies the system, dataset and public function to use. Once a dataset has been selected, inspect the current TABNET form:
options <- datasus_opcoes(
sistema = "sim",
conjunto = "obitos",
abrangencia = "uf"
)
options$linha
options$coluna
options$conteudo
names(options$filtros)Using the labels returned by datasus_opcoes() avoids
embedding assumptions about a form that the portal may change later.
sim() retrieves mortality data and sinasc()
retrieves live-birth data. Both accept a year, "last" for
the latest available period, and geographic or demographic filters.
deaths <- sim(
conjunto = "obitos",
abrangencia = "uf",
periodo = 2024,
coluna = "Ano do óbito"
)
male_deaths <- sim(
conjunto = "obitos",
uf = "MS",
periodo = 2024,
filtros = list(sexo = "Masculino")
)
births <- sinasc(
uf = "MS",
periodo = 2024,
coluna = "Ano do nascimento"
)The older sim_*() and sinasc_*() functions
remain as compatibility wrappers, but new code should use the unified
functions above.
Hospital, ambulatory and establishment tables follow the same conventions:
admissions <- sih_producao(
uf = "MS",
conteudo = "Internações",
periodo = 2025,
filtros = list(carater_atendimento = "Urgência")
)
procedures <- sia_producao(
uf = "MS",
conteudo = "Qtd.aprovada",
periodo = 2025
)
beds <- cnes(
conjunto = "leitos_internacao",
uf = "MS",
periodo = "last"
)
population <- populacao_residente(
uf = "MS",
periodo = 2021
)Use sih_morbidade() when the analysis is
diagnosis-oriented rather than production-oriented:
The catalog also covers disease-specific SINAN tables, immunization, nutritional surveillance, cancer screening and SUS financing:
Results carry a provenance record with the requested system, filters, source URL and retrieval time:
For a reproducible analysis, save the query arguments together with
the result, request explicit years instead of "last", and
record the package version: