microdados_baixar: Download raw DATASUS DBC files

View source: R/microdata.R

microdados_baixarR Documentation

Download raw DATASUS DBC files

Description

Discovers and downloads one or more official DBC files. Downloads use a dedicated cache below option 'datasus.cache_dir'; 'atualizar = TRUE' requests a fresh copy.

Usage

microdados_baixar(
  sistema,
  tipo = NULL,
  ano,
  mes = NULL,
  uf = NULL,
  destino = NULL,
  cache = TRUE,
  atualizar = FALSE,
  preliminares = TRUE,
  verificar = TRUE,
  timeout = 240
)

Arguments

sistema

System: '"sim"', '"sinasc"' or '"sih"'.

tipo

File type returned by [microdados_catalogo()]. 'NULL' selects the default type for the system.

ano

One or more four-digit years.

mes

One or more months from 1 to 12. Required for SIH.

uf

One or more state abbreviations, two-digit IBGE codes or state names. Required for UF-scoped types.

destino

Optional destination directory. 'NULL' uses the package cache, or a session temporary directory when 'cache = FALSE'.

cache

Whether to reuse the disk cache.

atualizar

Whether to request a fresh copy of already cached files.

preliminares

Whether preliminary directories may be considered.

verificar

Whether to verify file existence on the DATASUS server.

timeout

Network timeout in seconds for file discovery.

Value

A data frame describing the local files. Use [datasus_proveniencia()] for URLs and checksums.

Examples


old_options <- options(
  datasus.timeout = 5,
  datasus.download_timeout = 15,
  datasus.max_tries = 1
)
try({
files <- microdados_baixar("sih", ano = 2024, mes = 1, uf = "AC")
datasus_proveniencia(files)
})
options(old_options)


datasus documentation built on Oct. 7, 2026, 1:07 a.m.