| Title: | Download and Process 'DataSUS' Files |
|---|---|
| Description: | Downloads and processes health microdata from Brazilian Unified Health System ('DataSUS') information systems. It handles the compressed 'DBC' format internally and provides functions to organize variables and add labels to categorical fields from mortality, live births, hospital admissions, outpatient care, health facilities, and notifiable diseases data. For details, see Saldanha et al. (2019) <doi:10.1590/0102-311x00032419>. |
| Authors: | Raphael Saldanha [aut, cre] (ORCID: <https://orcid.org/0000-0003-0652-8466>), Sidney da Silva Pereira Bissoli [ctb, cph] (DBC decompression code), Mark Adler [ctb, cph] (blast decompressor) |
| Maintainer: | Raphael Saldanha <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 3.0.0 |
| Built: | 2026-09-28 07:38:32 UTC |
| Source: | https://github.com/rfsaldanha/microdatasus |
Provides a reproducible workflow for DataSUS microdata: fetch_datasus()
discovers, downloads, and combines published DBC files; read_dbc() reads a
local DBC file; and the process_*() functions convert system-specific
fields into analysis-ready values and labels.
Start with fetch_datasus() and then use the processor corresponding to the
selected system, such as process_sim(), process_sinasc(), process_sih(),
process_sia(), process_cnes(), or one of the process_sinan_*()
functions. fetch_cadger() and fetch_sigtab() retrieve current auxiliary
tables used by CNES and SIA processing.
For concepts, coverage, data flows, and caveats of each Brazilian health information system, see Saldanha (2026), Sistemas de Informação em Saúde no Brasil.
Maintainer: Raphael Saldanha [email protected] (ORCID)
Authors:
Raphael Saldanha [email protected] (ORCID)
Other contributors:
Sidney da Silva Pereira Bissoli (DBC decompression code) [contributor, copyright holder]
Mark Adler (blast decompressor) [contributor, copyright holder]
Useful links:
Report bugs at https://github.com/rfsaldanha/microdatasus/issues
CNES-PF sample with the first 100 rows from AC 2016-6 file.
cnes_pf_samplecnes_pf_sample
An object of class data.frame with 100 rows and 39 columns.
The variable CPF_PROF was removed due non-ASCII characters.
CNES-ST sample with the first 100 rows from AC 2016-6 file.
cnes_st_samplecnes_st_sample
An object of class data.frame with 100 rows and 201 columns.
Equipe table, based on INE_EQUIPE_BR.dbf file from SIM TabWIN definitions file.
equipeequipe
A data frame with 2428 rows and 2 variables:
Code
Label
Downloads and reads the current CNES establishment-name table distributed by
DataSUS. process_cnes() can use this table to add establishment names.
fetch_cadger(timeout = 240)fetch_cadger(timeout = 240)
timeout |
A positive numeric scalar. Download and connection timeout, in seconds. |
A data frame with character columns CNES (establishment code) and
FANTASIA (trade name).
This function downloads the current TAB_CNES.zip archive from DataSUS.
Transfer progress is displayed by default. The temporary archive and
extracted files are removed before the function returns or aborts.
Saldanha, R. F. (2026). CNES – Cadastro Nacional de Estabelecimentos de Saúde.
process_cnes(), fetch_datasus()
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 )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" )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" )
Downloads and reads the current SIA procedure table distributed by DataSUS.
process_sia() can use this table to add procedure descriptions.
fetch_sigtab(timeout = 240)fetch_sigtab(timeout = 240)
timeout |
A positive numeric scalar. Download and connection timeout, in seconds. |
A data frame with character columns COD (procedure code) and
nome_proced (procedure name).
This function downloads the current TAB_SIA.zip archive from DataSUS.
Transfer progress is displayed by default. The temporary archive and
extracted files are removed before the function returns or aborts.
Saldanha, R. F. (2026). SIA – Sistema de Informações Ambulatoriais do SUS.
process_sia(), fetch_datasus()
paisnet table, based on PAISNET.DBF file from CNES TabWIN definitions file.
paisnetpaisnet
A data frame with 266 rows and 3 variables:
Country code 1
Contry code 2
Label
Recodes supported CNES fields into descriptive values and normalizes escaped
Unicode text. Establishment ("CNES-ST") and professional ("CNES-PF")
records have different layouts and are processed accordingly.
process_cnes( data, information_system = c("CNES-ST", "CNES-PF"), nomes = FALSE, municipality_data = TRUE )process_cnes( data, information_system = c("CNES-ST", "CNES-PF"), nomes = FALSE, municipality_data = TRUE )
data |
A data frame returned by |
information_system |
A single character string: |
nomes |
Logical scalar. For |
municipality_data |
Logical scalar. If |
Columns not explicitly recoded are retained, but Unicode normalization is applied to every column and consequently the returned tibble contains character columns. Lookup joins can add establishment, occupation, and municipality information.
A tibble with character columns. Supported codes are replaced with descriptions, and requested lookup fields are added where applicable.
Saldanha, R. F. (2026). CNES – Cadastro Nacional de Estabelecimentos de Saúde.
fetch_datasus(), fetch_cadger()
process_cnes(cnes_st_sample, information_system = "CNES-ST") process_cnes(cnes_pf_sample, information_system = "CNES-PF")process_cnes(cnes_st_sample, information_system = "CNES-ST") process_cnes(cnes_pf_sample, information_system = "CNES-PF")
Recodes supported fields from SIA individual outpatient-production records
("SIA-PA") into descriptive values and normalizes escaped Unicode text.
Lookup joins can add procedure, occupation, team, and municipality
descriptions.
process_sia( data, information_system = "SIA-PA", nome_proced = TRUE, nome_ocupacao = TRUE, nome_equipe = TRUE, municipality_data = TRUE )process_sia( data, information_system = "SIA-PA", nome_proced = TRUE, nome_ocupacao = TRUE, nome_equipe = TRUE, municipality_data = TRUE )
data |
A data frame returned by |
information_system |
A single character string. Currently only
|
nome_proced |
Logical scalar. If |
nome_ocupacao |
Logical scalar. If |
nome_equipe |
Logical scalar retained for API compatibility. Team
descriptions are currently joined whenever |
municipality_data |
Logical scalar. If |
Columns not explicitly recoded are retained, but Unicode normalization is
applied to every column and consequently the returned tibble contains
character columns. Other SIA layouts downloadable with fetch_datasus() are
not currently supported by this processing function.
A tibble with character columns. Supported codes are replaced with descriptions, and requested lookup fields are added where applicable.
Saldanha, R. F. (2026). SIA – Sistema de Informações Ambulatoriais do SUS.
fetch_datasus(), fetch_sigtab()
process_sia(sia_pa_sample, nome_proced = FALSE)process_sia(sia_pa_sample, nome_proced = FALSE)
Recodes supported fields from reduced hospital-admission records
("SIH-RD") into descriptive values and normalizes escaped Unicode text.
process_sih(data, information_system = "SIH-RD", municipality_data = TRUE)process_sih(data, information_system = "SIH-RD", municipality_data = TRUE)
data |
A data frame returned by |
information_system |
A single character string. Currently only
|
municipality_data |
Logical scalar. If |
Columns not explicitly recoded are retained, but Unicode normalization is
applied to every column and consequently the returned tibble contains
character columns. Other SIH layouts downloadable with fetch_datasus() are
not currently supported by this processing function.
A tibble with character columns. Supported codes are replaced with descriptions, and municipality fields are added when requested and available.
Saldanha, R. F. (2026). SIH – Sistema de Informações Hospitalares do SUS.
process_sih(sih_rd_sample)process_sih(sih_rd_sample)
Recodes supported SIM mortality fields into descriptive values and normalizes escaped Unicode text. Codes without a documented conversion are retained.
process_sim(data, municipality_data = TRUE)process_sim(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar. If |
Columns not explicitly recoded are retained, but Unicode normalization is applied to every column and consequently the returned tibble contains character columns.
A tibble with character columns. Supported codes are replaced with descriptions, and municipality fields are added when requested and available.
Saldanha, R. F. (2026). SIM – Sistema de Informação sobre Mortalidade.
process_sim(sim_do_sample)process_sim(sim_do_sample)
Recodes supported fields from SINAN Chagas disease notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_chagas(data, municipality_data = TRUE)process_sinan_chagas(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar retained for API compatibility. It is not currently used by this processing function. |
A tibble with character columns. Supported codes are replaced with descriptions.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_chagas(sinan_chagas_sample)process_sinan_chagas(sinan_chagas_sample)
Recodes supported fields from SINAN chikungunya notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_chikungunya(data, municipality_data = TRUE)process_sinan_chikungunya(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar. If |
A tibble with character columns. Supported codes are replaced with descriptions, and municipality fields are added when requested and available.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_chikungunya(sinan_chikungunya_sample)process_sinan_chikungunya(sinan_chikungunya_sample)
Recodes supported fields from SINAN dengue notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_dengue(data, municipality_data = TRUE)process_sinan_dengue(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar. If |
A tibble with character columns. Supported codes are replaced with descriptions, and municipality fields are added when requested and available.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_dengue(sinan_dengue_sample)process_sinan_dengue(sinan_dengue_sample)
Recodes supported fields from SINAN tegumentary leishmaniasis notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_leishmaniose_tegumentar(data, municipality_data = TRUE)process_sinan_leishmaniose_tegumentar(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar retained for API compatibility. It is not currently used by this processing function. |
A tibble with character columns. Supported codes are replaced with descriptions.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_leishmaniose_tegumentar(sinan_leishmaniose_tegumentar_sample)process_sinan_leishmaniose_tegumentar(sinan_leishmaniose_tegumentar_sample)
Recodes supported fields from SINAN visceral leishmaniasis notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_leishmaniose_visceral(data, municipality_data = TRUE)process_sinan_leishmaniose_visceral(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar retained for API compatibility. It is not currently used by this processing function. |
A tibble with character columns. Supported codes are replaced with descriptions.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_leishmaniose_visceral(sinan_leishmaniose_visceral_sample)process_sinan_leishmaniose_visceral(sinan_leishmaniose_visceral_sample)
Recodes supported fields from SINAN malaria notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_malaria(data, municipality_data = TRUE)process_sinan_malaria(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar retained for API compatibility. It is not currently used by this processing function. |
A tibble with character columns. Supported codes are replaced with descriptions.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_malaria(sinan_malaria_sample)process_sinan_malaria(sinan_malaria_sample)
Recodes supported fields from SINAN Zika virus disease notifications into descriptive values and normalizes escaped Unicode text. Columns not explicitly recoded are retained, but the returned tibble contains character columns.
process_sinan_zika(data, municipality_data = TRUE)process_sinan_zika(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar retained for API compatibility. It is not currently used by this processing function. |
A tibble with character columns. Supported codes are replaced with descriptions.
Saldanha, R. F. (2026). SINAN – Sistema de Informação de Agravos de Notificação.
process_sinan_zika(sinan_zika_sample)process_sinan_zika(sinan_zika_sample)
Recodes supported SINASC live-birth fields into descriptive values and normalizes escaped Unicode text. Codes without a documented conversion are retained.
process_sinasc(data, municipality_data = TRUE)process_sinasc(data, municipality_data = TRUE)
data |
A data frame returned by |
municipality_data |
Logical scalar. If |
Columns not explicitly recoded are retained, but Unicode normalization is applied to every column and consequently the returned tibble contains character columns.
A tibble with character columns. Supported codes are replaced with descriptions, and municipality fields are added when requested and available.
Saldanha, R. F. (2026). SINASC – Sistema de Informação sobre Nascidos Vivos.
process_sinasc(sinasc_sample)process_sinasc(sinasc_sample)
Decompresses a DataSUS DBC file to a temporary DBF file and reads it into
a tibble. Use this function for a DBC file already available locally; use
fetch_datasus() to discover and download files from DataSUS.
read_dbc(file, as_character = TRUE)read_dbc(file, as_character = TRUE)
file |
A single character string with the path to a readable, non-empty DBC file. |
as_character |
If |
Decompression is performed through the package's bundled DBC implementation.
The intermediate DBF file is created in the R temporary directory and removed
before the function returns or aborts. The implementation was adapted from
the healthbR package.
Invalid input files, decompression failures, and DBF reading failures abort
with errors in the microdatasus_dbc_error family.
A tibble with one column per DBF field. By default, all columns are
character vectors; with as_character = FALSE, DBF-inferred types are
retained.
Saldanha, R. F. (2026). Sistemas de Informação em Saúde no Brasil.
SIA-PA sample with the first 100 rows from AC 2016-6 file.
sia_pa_samplesia_pa_sample
An object of class data.frame with 100 rows and 60 columns.
Procediments table, based on TB_SIGTAP.dbf file from SIA TabWIN definitions file.
sigtabsigtab
A data frame with 5325 rows and 2 variables:
Code
Procediment name
SIH-RD sample with the first 100 rows from AC 2016-6 file.
sih_rd_samplesih_rd_sample
An object of class data.frame with 100 rows and 113 columns.
SIM-DO sample with the first 100 rows from AC 2016 file.
sim_do_samplesim_do_sample
An object of class data.frame with 100 rows and 88 columns.
SINAN Chagas sample with the first 100 rows from the 2023 file.
sinan_chagas_samplesinan_chagas_sample
An object of class data.frame with 100 rows and 108 columns.
SINAN Chikungunya sample with the first 100 rows from the 2022 file.
sinan_chikungunya_samplesinan_chikungunya_sample
An object of class data.frame with 100 rows and 122 columns.
SINAN Dengue sample with the first 100 rows from the 2010 file.
sinan_dengue_samplesinan_dengue_sample
An object of class data.frame with 100 rows and 66 columns.
SINAN Leishmaniose Tegumentar sample with the first 100 rows from the 2023 file.
sinan_leishmaniose_tegumentar_samplesinan_leishmaniose_tegumentar_sample
An object of class data.frame with 100 rows and 74 columns.
SINAN Leishmaniose Visceral sample with the first 100 rows from the 2023 file.
sinan_leishmaniose_visceral_samplesinan_leishmaniose_visceral_sample
An object of class data.frame with 100 rows and 76 columns.
SINAN Malaria sample with the first 100 rows from the 2016 file.
sinan_malaria_samplesinan_malaria_sample
An object of class data.frame with 100 rows and 50 columns.
SINAN Zika sample with the first 100 rows from the 2016 file.
sinan_zika_samplesinan_zika_sample
An object of class data.frame with 100 rows and 38 columns.
SINASC sample with the first 100 rows from AC 2016 file.
sinasc_samplesinasc_sample
An object of class data.frame with 100 rows and 61 columns.
CBO table, based on CBO2002.CNV file from SIM TabWIN definitions file.
tabCBOtabCBO
A data frame with 2428 rows and 2 variables:
Code
Label
Municipalities table
tabMuntabMun
A data frame with 5659 rows and 2 variables:
Municipality IBGE code with 6 numbers
Status
Type
Name
UF (state)
Latitude
Longitude
Altitude
Area
Naturalidade table, based on NATUR.CNV file from SIM TabWIN definitions file.
tabNaturalidadetabNaturalidade
A data frame with 292 rows and 2 variables:
Code
Label
Ocupations table, based on OCUPACAO.CNV file from SIM TabWIN definitions file.
tabOcupacaotabOcupacao
A data frame with 350 rows and 2 variables:
Code
Label