datazoom.saude is an R package that downloads, cleans and standardizes Brazilian public health microdata from DATASUS (SIM, SINASC, SIH, SIA, CNES, PO and SI-PNI) with a single function call. It is developed by Data Zoom, a research group at the Department of Economics of the Pontifical Catholic University of Rio de Janeiro (PUC-Rio), and is available on CRAN.
Português: o
datazoom.saudeé um pacote R que baixa, limpa e padroniza microdados de saúde pública do DATASUS (mortalidade, nascidos vivos, internações, procedimentos ambulatoriais, leitos, oncologia e vacinação), com nomes de variáveis em inglês ou português. Página do projeto: https://datazoom.com.br/pt/dz_saude/.
Overview
The datazoom.saude package provides simple, direct, and reliable functions to import, organize, and explore public health databases in Brazil. It is part of the datazoom ecosystem, designed to simplify access to and analysis of national data.
About DATASUS
DATASUS is the information technology department of SUS — the Brazilian Unified Health System. It maintains a wide range of open databases covering topics such as health establishments, mortality, access to healthcare services, hospital admissions, births, and epidemiological indicators across the country.
The datazoom.saude package streamlines access to these resources by:
- Downloading multiple raw DATASUS datasets automatically;
- Cleaning and standardizing selected datasets for easier analysis;
- Decompressing DATASUS’s
.dbcfiles internally (seedbc2dbf_wrapper()); - Providing consistent structures across data sources for seamless integration, with variable names and labels in English or Portuguese.
Each supported dataset is detailed in the sections below.
A note on caching
Downloaded .dbc files are cached on disk in temporary session directories (tempdir()) for the lifetime of the current R session. Re-running a query for the same file (for example, switching language or raw_data) reuses the local cached file instead of hitting DATASUS FTP again. Cached files are never persisted across sessions and are removed automatically when R exits. Set options(datazoom.saude.cache = FALSE) to disable caching.
Connection Reliability & Automatic Retries
The official DATASUS FTP server (ftp.datasus.gov.br) intermittently drops connections mid-transfer. To prevent transient network failures from interrupting multi-year or multi-state queries, every FTP file transfer is automatically retried up to 3 times with backoff when a connection drops or a partial file is received.
Installation
You can install the released version of datazoom.saude from CRAN, the latest build from r-universe, or the development version from GitHub.
# From CRAN:
install.packages("datazoom.saude")
# From r-universe (binaries of the development version):
install.packages("datazoom.saude",
repos = c("https://datazoompuc.r-universe.dev", "https://cloud.r-project.org"))
# Or the development version from GitHub:
# Install the 'remotes' package if you don't have it yet
install.packages("remotes")
# Install datazoom.saude directly from GitHub
remotes::install_github("datazoompuc/datazoom.saude")Quick example
library(datazoom.saude)
# Deaths (SIM) in Rio de Janeiro state in 2022, cleaned, with English labels
deaths <- load_mortality(dataset = "general", time_period = 2022, states = "RJ")
# Live births (SINASC) for São Paulo, 2020-2021, with Portuguese labels
births <- load_births(time_period = 2020:2021, states = "SP", language = "pt")Supported Databases
| # | DATASUS system | Full name | Function | Guide |
|---|---|---|---|---|
| 1 | SIM | Mortality Information System (Sistema de Informações sobre Mortalidade) | load_mortality() |
Mortality |
| 2 | SINASC | Live Birth Information System (Sistema de Informações sobre Nascidos Vivos) | load_births() |
Live Births |
| 3 | SIH/SUS | Hospital Information System (Sistema de Informações Hospitalares) | load_hospital_admissions() |
Hospital Admissions |
| 4 | CNES-LT | Hospital beds from the National Registry of Health Establishments (Cadastro Nacional de Estabelecimentos de Saúde) | load_hospital_beds() |
Hospital Beds |
| 5 | SIA/SUS | Outpatient Information System (Sistema de Informações Ambulatoriais) | load_outpatient_procedures() |
Outpatient Procedures |
| 6 | PO | Oncology Panel (Painel de Oncologia) | load_oncology_case() |
Oncology Cases |
| 7 | SI-PNI | National Immunization Program Information System (Sistema de Informação do Programa Nacional de Imunizações) | load_vaccines() |
Vaccines |
For detailed usage examples and guides on each database, please refer to the sections (vignettes) below.
Mortality
The load_mortality function provides access to the System of Mortality Information (SIM) datasets, which contain detailed information about deaths in Brazil. Each original SIM data file includes rows corresponding to a declaration of death (DO) and columns with several characteristics of the person, the place of death, and the cause of death.
The load_mortality function offers the following parameters:
-
dataset: Specifies the SIM dataset to download:
- SIM Datasets:
-
"general"– Main Declarations of Death. (National dataset available —states = "all") Contains records of all non-fetal Death Certificates (DO) in Brazil, including socio-demographic data, location, and causes of death (ICD-10). It’s the base for general mortality analysis. (since 1979 to present) -
"fetal"– Fetal mortality data. (National dataset not available) Contains records of fetal deaths, with information on the mother, pregnancy, and causes of fetal death. It’s essential for maternal and child health. (since 1979 to present) -
"external_causes"– Mortality data from external causes. (National dataset not available) Contains a subset of"general"focusing on deaths due to accidents, violence, and other unnatural causes. Used for safety and prevention studies. (since 1979 to present) -
"infant"– Infant mortality data (children). (National dataset not available) Contains a subset of"general"recording deaths of children under 1 year old, detailing causes and birth-related factors. Crucial for assessing child health. (since 1979 to present) -
"maternal"– Maternal mortality data. (National dataset not available) Contains a subset of"general"for deaths of women during or shortly after pregnancy/childbirth, detailing obstetric causes. Important for women’s health. (since 1996 to present)
-
- SIM Datasets:
time_period: a numeric value or vector indicating the year(s) of the data to be downloaded. For example,
2020or2015:2020.states: (valid only for the
generaldataset) — a string or a vector of strings indicating the Brazilian state(s) for which the data should be downloaded. The default is"all", which downloads data for the entire country. For specific states, use the official abbreviations such as"SP"(São Paulo),"RJ"(Rio de Janeiro), orc("SP", "RJ").-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
keep_all: A boolean choosing whether to aggregate the data by municipality, losing individual-level variables (
FALSE) or to keep all original variables (TRUE). Only applies whenraw_dataisFALSE.language: A string indicating the desired language of variable names and labels. Accepts
"eng"(default) for English or"pt"for Portuguese (only whenraw_data = FALSE).
Examples:
library(datazoom.saude)
# Download raw data for general mortality - State of Rio de Janeiro, 2022.
raw_data_general_rj <- load_mortality(
dataset = "general",
time_period = 2022,
states = "RJ",
raw_data = TRUE
)
# Download treated data for general mortality - States of Rio and São Paulo, 2022.
trated_data_general_rj <- load_mortality(
dataset = "general",
time_period = 2022,
states = c("RJ", "SP"),
raw_data = FALSE,
keep_all = FALSE # Explicitly stating default behavior
)
# Download treated data for Maternal Deaths - Brazil, 2020 to 2022.
# Descriptions in Portuguese.
# Note: `maternal` does not provide separate files by state.
data_maternal_pt <- load_mortality(
dataset = "maternal",
time_period = 2020:2022,
states = "all",
raw_data = FALSE,
language = "pt"
)
# Download treated data for Infant Deaths - Brazil, 2017.
# Keeping all individual variables (not aggregated).
data_infant_full <- load_mortality(
dataset = "infant",
time_period = 2017,
states = "all",
raw_data = FALSE,
keep_all = TRUE,
language = "eng"
)
# Download treated data for Fetal Deaths - State of Amazonas, 2000.
data_infant_full <- load_mortality(
dataset = "fetal",
time_period = 2000,
states = "AM",
raw_data = FALSE,
language = "eng"
)
# Download treated data for External Causes Deaths - State of Acre, 2022.
data_infant_full <- load_mortality(
dataset = "fetal",
time_period = 2022,
states = "AC",
raw_data = FALSE,
language = "eng"
)Live Births
The load_births function provides access to the Live Birth Information System (SINASC) dataset, which collects and records detailed information about births in Brazil. This data is extracted from Live Birth Certificates (DNVs) and includes information about the newborn, such as sex, weight, and gestational age, as well as data about the mother, such as age, number of children and health conditions (since 1994 to present). SINASC is essential for monitoring maternal and child health and generating relevant indicators for public health policy formulation.
The load_births function offers the following parameters:
time_period: A numeric value or vector indicating the year(s) of the data to be downloaded. For
example,2020or2015:2020. (since 1994 to present)states: A string or array of strings indicating the Brazilian state(s) for which data should be
downloaded. Use “all” (by default) to download data for the entire country. For specific states, use abbreviations such as “SP”, “RJ”, or c(“SP”, “RJ”).-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
language: A string indicating the desired language of variable names and labels. Accepts “eng” (default) for English or “pt” for Portuguese.
Examples:
library(datazoom.saude)
# Download raw birth data for 2023 in the state of Rio de Janeiro (RJ).
data_raw_births <- load_births(
time_period = 2023,
states = "RJ"
)
# Download raw birth data for 2020 in the states of Rio de Janeiro (RJ) and São Paulo (SP),
# keeping the original raw format.
data_raw_births2 <- load_births(
time_period = 2020,
states = c("RJ","SP"),
raw_data = TRUE
)
# Download raw birth data for 2014 in the state of Amazonas (AM),
# with variable labels in Portuguese.
data_raw_births3 <- load_births(
time_period = 2014,
states = "AM",
language = "pt"
)
# Download processed birth data for 2015 in the state of Amazonas (AM),
# with variable labels in Portuguese for easier analysis.
data_processed_births <- load_births(
time_period = 2015,
states = "AM",
raw_data = FALSE,
language = "pt"
)Hospital Admissions
The load_hospital_admissions function provides access to multiple datasets from the Hospital Information System (SIH), which record detailed information about hospital admissions funded by Brazil’s public health system (SUS). Each row corresponds to a Hospital Admission Authorization (AIH), and the files are organized by the type of information they contain.
The load_hospital_admissions function offers the following parameters:
-
dataset: Specifies the SIH dataset to download:
- SIH hospitalization data is split across four datasets (since Jan/2008 to present):
-
"reduced_aih"– Reduced AIHs (summary of hospitalizations). Contains consolidated information about approved and processed AIHs, including the main procedure performed, related diagnoses, and total costs. This is the most commonly used dataset for statistical and epidemiological analyses. -
"professional_services"– Professional Services performed during hospitalization. Provides detailed records of the professional services carried out during hospital stays, including procedures performed, professionals involved (CBO/CNS), and amounts paid for medical and hospital services. -
"rejected_aih"– Rejected AIHs (general reason). Includes consolidated records of AIHs that were rejected, specifying the general reason for the rejection but without detailed error codes. Useful for analyzing the volume and impact of rejections. -
"rejected_aih_error"– Rejected AIHs with specific error codes. Contains AIHs that were rejected due to inconsistencies found during processing. Each rejection includes a specific error code indicating the reason (e.g., invalid patient data, procedure incompatibilities).
-
- SIH hospitalization data is split across four datasets (since Jan/2008 to present):
time_period: a numeric value or vector indicating the year(s) of the data to be downloaded. For example,
2020or2015:2020.states: a string or vector of strings indicating the Brazilian state(s) for which the data should be downloaded. Use
"all"to download data for the entire country. For specific states (valid only for thegeneraldataset), use abbreviations like"SP"(São Paulo),"RJ"(Rio de Janeiro), orc("SP", "RJ").-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
language: A string indicating the desired language of variable names and labels. Accepts
"eng"(default) for English or"pt"for Portuguese (only whenraw_data = FALSE).
Examples:
library(datazoom.saude)
# Download raw data for Reduced AIHs (AIHs Reduzida) – All country, 2010.
data_rd_raw <- load_hospital_admissions(
dataset = "reduced_aih",
time_period = 2010,
states = "all",
raw_data = TRUE,
language = "eng"
)
# Download processed data for Rejected AIHs with Error Codes – State of Amazonas, 2010 to 2020.
# Descriptions in Portuguese.
data_er_processed <- load_hospital_admissions(
dataset = "rejected_aih_error",
time_period = 2010:2020,
states = "AM",
raw_data = FALSE,
language = "pt"
)
# Download raw data for Professional Services – States of Rio and São Paulo, 2022.
data_sp_raw <- load_hospital_admissions(
dataset = "professional_services",
time_period = 2022,
states = C("RJ","SP"),
raw_data = TRUE,
language = "eng"
)
# Download processed data for Professional Services – Federal District, 2020 to 2022.
# Descriptions in Portuguese.
data_sp_processed <- load_hospital_admissions(
dataset = "professional_services",
time_period = 2020:2022,
states = "DF",
raw_data = FALSE,
language = "pt"
)Hospital Beds
The load_hospital_beds function specifically focuses on the CNES - LT (Beds) dataset, part of the National Register of Health Establishments (CNES). This dataset provides information on the number of available hospital beds in health establishments across Brazil (since Out/2005 to present).
The load_hospital_beds function offers the following parameters:
time_period: a numeric value or vector indicating the year(s) of the data to be downloaded. For example,
2020or2015:2020. (since Out/2005 to present)states: a string or vector of strings indicating the Brazilian state(s) for which the data should be downloaded. Use
"all"to download data for the entire country. For specific states (valid only for thegeneraldataset), use abbreviations like"SP"(São Paulo),"RJ"(Rio de Janeiro), orc("SP", "RJ").-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
keep_all: A boolean choosing whether to aggregate the data by municipality, losing individual-level variables (
FALSE) or to keep all original variables (TRUE). Only applies whenraw_dataisFALSE.language: A string indicating the desired language of variable names and labels. Accepts
"eng"(default) for English or"pt"for Portuguese (only whenraw_data = FALSE).
Examples:
library(datazoom.saude)
# Download treated data - States of Amazonas and Pará, 2010.
data_beds_full <- load_hospital_beds(
time_period = 2010,
states = c("AM", "PA"),
raw_data = FALSE,
language = "eng"
)
# Download treated data - Brrazil, 2010 to 2022.
# Descriptions in Portuguese.
data_beds_full <- load_hospital_beds(
time_period = 2010:2022,
states = "all",
raw_data = FALSE,
language = "pt"
)
# Download raw data - States of Rio de Janeiro, 2015.
data_beds_raw <- load_hospital_beds(
time_period = 2015,
states = "RJ",
raw_data = TRUE,
language = "eng"
)Outpatient Procedures
The load_outpatient_procedures function provides access to various SIASUS (Ambulatory Information System) datasets, covering a broad spectrum of outpatient services funded by the public health system (SUS). Each row in these datasets corresponds to a procedure performed at an outpatient level, including clinical, administrative, and financial details. The data is organized by type of service or procedure group.
Note: In all SIASUS datasets, variables related to the Cadastro Nacional de Saúde (CNS – National Health Card number) are encrypted by DATASUS.
This ensures patient confidentiality and means that individual-level CNS identifiers cannot be directly used for linkage across datasets. Because of this, this variable is removed whenraw_data = FALSE.
The load_outpacient_procedures function offers the following parameters:
-
dataset: Specifies the SIASUS dataset to download:
-
"ambulatory_production"– Consolidated Outpatient Procedures (Procedimentos Ambulatoriais). Contains records of approved outpatient procedures across all specialties. This is the most comprehensive SIASUS dataset and is often used for general outpatient service analysis. (since Jul/1994 to present) -
"bariatric_surgery"– Pre-Bariatric Surgery (Pré Cirurgia Bariátrica). Records related to bariatric surgery procedures performed in outpatient settings. (Jan/2008 to Mar/2013) -
"bariatric_surgery_follow_up"– Bariatric Surgery Follow-Up (Acompanhamento Bariátrico). Includes follow-up care for patients who have undergone bariatric surgery, focusing on long-term monitoring and outcomes. (since Apr/2013 to present) -
"fistula_confection"– Vascular Access for Dialysis (Fístula Arteriovenosa). Documents procedures involving the creation or maintenance of arteriovenous fistulas, essential for hemodialysis treatment. (since Jun/2014 to present) -
"diverse_reports"– Miscellaneous Specialized Procedures (Laudos Diversos) Covers less frequent or highly specialized outpatient procedures not classified in other datasets. (since Jan/2008 to present) -
"medicines"– High-Cost Medications (Medicamentos) Tracks the distribution and usage of outpatient medications that are high-cost and part of specific therapeutic programs. (since Jan/2008 to present) -
"nephrology"– Nephrology / Dialysis (Nefrologia) Contains outpatient nephrology procedures, particularly related to the care and monitoring of patients with chronic kidney disease. (Jan/2008 to Out/2024) -
"dialytic_treatment"– Dialysis Treatment (Tratamento Dialítico) Includes outpatient dialysis treatment sessions for patients with kidney failure. (since Jun/2014 to present) -
"psychosocial"– RAAS Psychosocial Care (RAAS Psicossocial) Part of the Specialized Outpatient Mental Health Services. Records care provided through Psychosocial Care Centers (CAPS), including treatments for severe mental disorders and substance use. (since Jan/2013 to present) -
"home_care"– RAAS Home Care (RAAS Atenção Domiciliar) Focuses on outpatient care provided at patients’ homes, often involving chronic condition management, palliative care, and multi-professional follow-ups. (since Nov/2012 to present)
-
time_period: a numeric value or vector indicating the year(s) of the data to be downloaded. For example,
2020or2015:2020.states: a string or vector of strings indicating the Brazilian state(s) for which the data should be downloaded. Use
"all"to download data for the entire country. For specific states (valid only for thegeneraldataset), use abbreviations like"SP"(São Paulo),"RJ"(Rio de Janeiro), orc("SP", "RJ").-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
language: A string indicating the desired language of variable names and labels. Accepts
"eng"(default) for English or"pt"for Portuguese (only whenraw_data = FALSE).
Examples:
library(datazoom.saude)
# Download processed data for Post-Bariatric Surgery Follow-Up (ABO) – State of Acre, 2012.
bariatric_surgery_follow_up <- load_outpatient_procedures(
dataset = "bariatric_surgery_follow_up",
time_period = 2012,
states = "AC",
raw_data = FALSE,
language = "eng"
)
# Download processed data for Consolidated Outpatient Procedures (PA) – State of Acre, 2022.
# Descriptions in Portuguese.
ambulatory_production <- load_outpatient_procedures(
dataset = "ambulatory_production",
time_period = 2022,
states = "AC",
raw_data = FALSE,
language = "pt"
)
# Download raw data for High-Cost Medications (AM) - State of Pernambuco, 2021.
medicines_raw <- load_outpatient_procedures(
dataset = "medicines",
time_period = 2021,
states = "PE",
raw_data = TRUE,
language = "eng"
)
# Download processed data for Psychosocial Care (PS) - State of Acre, 2022 to 2023.
psychosocial <- load_outpatient_procedures(
dataset = "psychosocial",
time_period = 2022:2023,
states = "AC",
raw_data = FALSE,
language = "eng"
)Oncology Cases
The load_oncology_case function downloads and organizes data from the Oncology Panel (Painel de Oncologia), part of DATASUS. This dataset is widely used in public health and epidemiological analyses related to cancer cases in Brazil (since 2013 to present).
The load_oncology_case function offers the following parameters:
time_period: a numeric value or vector indicating the year(s) of the data to be downloaded. For example,
2020or2015:2020. (since 2013 to present)-
raw_data: Logical, default is
FALSE.-
TRUE: If TRUE, returns the raw data exactly as provided by DATASUS. -
FALSE: If FALSE (default), returns a cleaned and standardized version of the dataset.
-
language: A string indicating the desired language of variable names and labels. Accepts
"eng"(default) for English or"pt"for Portuguese (only whenraw_data = FALSE).
Examples:
library(datazoom.saude)
# Download processed oncology data for the year 2023.
# This will return data from the Oncology Panel for all Brazilian states.
oncology_cases_treated <- load_oncology_case(
time_period = 2023,
raw_data = FALSE,
language = "eng"
)
# Download raw oncology data for the years 2021 to 2022 with labels in portuguese.
oncology_cases_raw <- load_oncology_case(
time_period = 2021:2022,
raw_data = TRUE,
language = "pt"
)Vaccines
The load_vaccines() function provides access to the National Immunization Program Information System (SI-PNI). This dataset contains records of vaccine doses applied across Brazil, allowing for the analysis of immunization coverage and public health strategies.
The load_vaccines function offers the following parameters:
-
year: A numeric value indicating the year of the data to be downloaded.
- Currently supported range:
1994to present. - Note: You must input only one year at a time.
- Currently supported range:
-
state: A string indicating the Brazilian state abbreviation for which the data should be downloaded (e.g.,
"SP","RJ","AC").- Note: You must input only one state at a time.
-
strategy: Specifies the vaccination strategy.
- Common strategies include:
-
"Rotina"– Routine vaccination schedule. -
"Especial"– Special immunobiologicals. -
"Bloqueio"– Blocking vaccination in outbreak areas. -
"Intensificação"– Intensification campaigns. -
"Serviço Privado"– Data from private clinics.
-
- Note: If set to
NULL, a selection menu will appear.
- Common strategies include:
-
product: Specifies the specific vaccine or immunobiological product (e.g.,
"BCG - BCG","Febre amarela - FA","Hepatite B - HB").- The valid options for product depend strictly on the chosen strategy.
- Note: If set to
NULL, a selection menu will appear.
-
dose: A character vector indicating the dose categories that were selected when downloading the data.
- This argument is only required when using manually downloaded files up to 2023.
- The values must correspond to the “Dose” filter used (e.g.,
"D1",c("D1", "2"),"Única", etc.).
- The values must correspond to the “Dose” filter used (e.g.,
- This argument is only required when using manually downloaded files up to 2023.
-
data: Optional path to a local
.xlsor.xlsxfile downloaded manually.- If provided,
load_vaccines()will skip HTTP retrieval and only perform data cleaning and harmonization. - This argument is optional for data up to 2023, but required for data from 2024 onwards.
- If provided,
-
language: A string indicating the desired language of variable names and labels.
- Accepts
"eng"(default) for English or"pt"for Portuguese.
- Accepts
Data ingestion modes
The function supports two distinct data ingestion modes, depending on the availability and stability of the official SI-PNI portals:
-
Automated retrieval for all supported years:
-
1994–2023: via direct HTTP requests to the legacy SI-PNI Web system. -
2024–present: via direct Qlik Engine queries to the new DATASUS interactive dashboard (infoms.saude.gov.br).
-
-
Manual data ingestion (optional), where the user downloads the data directly from the official DATASUS dashboard and provides it via
data, in which case the function performs only cleaning, harmonization, and standardization.
Both modes produce a fully harmonized output, consistent with the historical SI-PNI data structure.
1. Automated retrieval (1994 - present)
load_vaccines() can automatically retrieve consolidated vaccination data across the entire historical and recent series (1994 to present) without requiring Google Chrome or headless browsers.
This mode:
- Requires a stable internet connection.
- Depends on the availability and responsiveness of the DATASUS SI-PNI portals.
- Uses direct HTTP requests (
1994–2023) and Qlik Engine JSON-RPC WebSocket queries (2024–present).
No manual intervention is required from the user.
2.1. Manual download (1994 - 2023)
From 1994 to 2023, vaccination data are available through the legacy SI-PNI Web system. Although load_vaccines() can retrieve these data automatically via direct HTTP requests, users may also choose to manually download the data and provide the file to the function for harmonization.
In this case, load_vaccines() will perform only the cleaning, harmonization, and standardization steps, ensuring that the resulting dataset follows the same structure as the automatically collected data.
This approach can be useful when:
- The SI-PNI website is unstable or slow
- The user already possesses previously downloaded data
- The user prefers manual control over the data retrieval process
Step-by-step instructions for manual download
Access the DATASUS vaccination dashboard:
https://sipni.datasus.gov.br/si-pni-web/faces/relatorio/consolidado/dosesAplicadasMensal.jsfIn the filter panel, fill only the following fields:
- UF
- Ano
- Estratégia
- Produto
- Dose
(Do not apply any additional filters)
Select the option “Totalizar por Município”.
Click “Pesquisar” and wait for the table to be generated.
Below the table, locate the section “Exportar Para o Formato” and click on the first icon (
.xls) to download the data.Provide the downloaded file to
load_vaccines()using thedataargument.
2.2. Manual download (2024 - present)
From 2024 onwards, vaccination data are published through the new DATASUS interactive dashboard (infoms.saude.gov.br). Although load_vaccines() retrieves these data automatically, users may also choose to manually download the .xlsx file and provide it via the data argument.
In this case, load_vaccines() will perform only the cleaning, harmonization, and standardization steps.
Step-by-step instructions for manual download
Access the DATASUS vaccination dashboard:
https://infoms.saude.gov.br/extensions/SEIDIGI_DEMAS_VACINACAO_CALENDARIO_NACIONAL_OCORRENCIA/SEIDIGI_DEMAS_VACINACAO_CALENDARIO_NACIONAL_OCORRENCIA.htmlIn the filter panel, fill only the following fields:
- UF Ocorrência
- Ano Vacina
- Estratégia de Vacinação
- Imunobiológico
- Doses
(Do not apply any additional filters)
Switch to the “Tabelas” tab.
In the table configuration:
- Add the variable “Tipo Dose” (at the left side) to the table.
- Expand all rows to display the full table.
Click “Baixar Dados” and save the file in
.xlsxformat.Provide the downloaded file to
load_vaccines()using thedataargument.
Interactive Mode:
If you are unsure of the exact strings for strategy or product, you can run the function providing only the year and state. The function will provide an interactive menu in the R console for you to choose from valid combinations. (The interactive mode is only valid for data between 1994 and 2022)
Examples:
library(datazoom.saude)
# Download data for Yellow Fever via web scraping (Routine strategy) - State of Acre, 2020
data_fa_acre <- load_vaccines(
year = 2020,
state = "AC",
strategy = "Rotina",
product = "Febre amarela - FA",
language = "eng"
)
# Download data for BCG via web scraping (Private Service strategy) - State of São Paulo, 2018
data_bcg_sp <- load_vaccines(
year = 2018,
state = "SP",
strategy = "Serviço Privado",
product = "BCG - BCG",
language = "pt"
)
# Download data for Trivalent Influenza using a manually downloaded file (Blockade strategy) - State of Acre, 2018
data_fa_acre <- load_vaccines(
year = 2018,
state = "AC",
strategy = "Bloqueio",
product = "Influenza Trivalente - FLU3V",
doses = c("D1", "DU", "REV", "DI"), # required for data up to 2022
data = "C:/path/to/downloaded_file.xls", #.xls
language = "eng"
)
# Download data for Trivalent Influenza using a manually downloaded file (Blockade strategy) - State of Minas Gerais, 2024
data_fa_acre <- load_vaccines(
year = 2024,
state = "MG",
strategy = "Bloqueio",
product = "Influenza Trivalente - FLU3V",
doses = NULL, # not required for data 2023 onwards
data = "C:/path/to/downloaded_file.xls", #.xls
language = "pt"
)
# Example of calling the function to trigger interactive selection - State of Minas Gerais, 2010
data_interactive <- load_vaccines(
year = 2010,
state = "MG",
language = "pt")Technical Note:
- Automated retrieval relies on the legacy SI-PNI Web system and is subject to instability, timeouts, and unexpected failures on the DATASUS side.
- For recent years (2024 onwards), manual download via the DATASUS dashboard is the supported data source.
- Regardless of the ingestion mode,
load_vaccines()always returns a harmonized dataset with consistent variable names, dose categories, and structure.
Important: For the automated retrieval mode, please be aware that the SI-PNI website (https://sipni.datasus.gov.br/si-pni-web/faces/relatorio/consolidado/dosesAplicadasMensal.jsf) can experience temporary server-side instability. The function includes built-in retries to handle connection resets. If the function fails, it is recommended to wait a few minutes and try again.
Related packages
datazoom.saude is part of the Data Zoom ecosystem of open tools for Brazilian microdata:
-
datazoom.amazonia(R, CRAN): environmental, economic and social data on the Brazilian Amazon. -
datazoom.social(R, CRAN): IBGE’s PNAD Contínua microdata, with panel identification. -
datazoom_socialfor Stata (GitHub): IBGE household surveys (PNAD, PNAD Contínua, Census, POF, PME and more). - Data Zoom website: https://datazoom.com.br/en/ (English) and https://datazoom.com.br/pt/ (Português).
Contributing
Thank you for your interest in contributing! If you have found a bug or have a suggestion for improvement, please open a GitHub issue.
Credits
DataZoom is developed by a team at the Pontifícia Universidade Católica do Rio de Janeiro (PUC-Rio), Department of Economics. Project pages: https://datazoom.com.br/en/dz_saude/ (English) and https://datazoom.com.br/pt/dz_saude/ (Português).
Citation
To cite datazoom.saude in publications, run citation("datazoom.saude") in R, or use:
Tavares Regadas L, Laport Santos L, dos Santos P. Barbosa JP, B. A. de Souza VA (2026). datazoom.saude: Download Brazilian Public Health Microdata from DATASUS. Data Zoom, Department of Economics, Pontifical Catholic University of Rio de Janeiro (PUC-Rio). R package version 0.1.1. https://CRAN.R-project.org/package=datazoom.saude
A BibTeX entry for LaTeX users is:
@Manual{datazoom.saude,
title = {{datazoom.saude}: Download Brazilian Public Health Microdata from {DATASUS}},
author = {Laura {Tavares Regadas} and Luana {Laport Santos} and Jo{\~a}o Paulo {dos Santos P. Barbosa} and Vanndher Am{\'o}s {B. A. de Souza}},
organization = {Data Zoom, Department of Economics, Pontifical Catholic University of Rio de Janeiro (PUC-Rio)},
year = {2026},
note = {R package version 0.1.1},
url = {https://CRAN.R-project.org/package=datazoom.saude},
}GitHub users can also use the “Cite this repository” button, generated from CITATION.cff.
