View source: R/fetch_datasus.R
| fetch_datasus | R Documentation |
Downloads published DBC files from DataSUS, reads them with read_dbc(),
and combines the records in deterministic period, state, and file-part order.
fetch_datasus(
year_start,
month_start = NULL,
year_end,
month_end = NULL,
uf = "all",
information_system,
vars = NULL,
stop_on_error = FALSE,
timeout = 240,
track_source = FALSE,
quiet = FALSE
)
year_start, year_end |
Numeric scalars giving the first and last requested years, inclusive. |
month_start, month_end |
Numeric scalars giving the first and last requested months, inclusive. Months are required for SIH, SIA, and CNES systems and ignored, with a warning, for annual systems. |
uf |
A Brazilian state abbreviation, a character vector of
abbreviations, or |
information_system |
A single system identifier listed in Supported systems. |
vars |
|
stop_on_error |
Logical scalar. If |
timeout |
A positive numeric scalar giving the connection and transfer timeout, in seconds, for each network attempt. |
track_source |
Logical scalar. If |
quiet |
Logical scalar. If |
The function first lists the relevant DataSUS directories and downloads only files present in those listings. When more than one publication represents the same system, period, state, and file part, definitive/current data take precedence over preliminary data, and current data take precedence over historical copies.
Downloads are sequential. Unless quiet = TRUE, transfer progress is
displayed by curl::curl_download(). Transient network failures are retried
up to two times; missing, empty, invalid DBC, and incompatible-schema files
are not retried. Partial files and other temporary files are removed before
the function returns or aborts.
Years and state abbreviations refer to DataSUS processing periods and places of processing, which may differ from dates or places of occurrence and residence contained in the records.
A tibble containing all successfully read records, or NULL if no
requested file could be read. No diagnostic attributes are added.
SIH: "SIH-RD", "SIH-RJ", "SIH-SP", and "SIH-ER".
SIM: "SIM-DO", "SIM-DOFET", "SIM-DOEXT", "SIM-DOINF", and
"SIM-DOMAT".
SINASC: "SINASC".
CNES: "CNES-LT", "CNES-ST", "CNES-DC", "CNES-EQ",
"CNES-SR", "CNES-HB", "CNES-PF", "CNES-EP", "CNES-RC",
"CNES-IN", "CNES-EE", "CNES-EF", and "CNES-GM".
SIA: "SIA-AB", "SIA-ABO", "SIA-ACF", "SIA-AD", "SIA-AN",
"SIA-AM", "SIA-AQ", "SIA-AR", "SIA-ATD", "SIA-PA", "SIA-PS",
and "SIA-SAD".
SINAN: "SINAN-DENGUE", "SINAN-CHIKUNGUNYA", "SINAN-ZIKA",
"SINAN-MALARIA", "SINAN-CHAGAS",
"SINAN-LEISHMANIOSE-VISCERAL",
"SINAN-LEISHMANIOSE-TEGUMENTAR", and "SINAN-LEPTOSPIROSE".
An Internet connection and FTP access to DataSUS are required. DataSUS may restrict FTP access from some countries.
Saldanha, R. F. (2026). Sistemas de Informação em Saúde no Brasil, especially the chapters on SIM, SINASC, SIH, SIA, SINAN, and CNES.
read_dbc() for local DBC files; process_sim(), process_sinasc(),
process_sih(), process_sia(), process_cnes(), and the
process_sinan_*() functions for system-specific recoding.
sim <- fetch_datasus(
year_start = 2014,
year_end = 2014,
uf = "AC",
information_system = "SIM-DO",
vars = c("CODMUNRES", "DTOBITO", "CAUSABAS")
)
sih <- fetch_datasus(
year_start = 2014,
month_start = 1,
year_end = 2014,
month_end = 2,
uf = c("AC", "RR"),
information_system = "SIH-RD"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.