fetch_datasus: Fetch and read microdata files from DataSUS

View source: R/fetch_datasus.R

fetch_datasusR Documentation

Fetch and read microdata files from DataSUS

Description

fetch_datasus downloads microdata (DBC) files from DataSUS and reads them.

Usage

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
)

Arguments

year_start, year_end

numeric. Start and end year of files in the format yyyy.

month_start, month_end

numeric. Start and end month in the format mm. Those parameters are only used with the healh information systems SIH, CNES and SIA. There parameter are ignored if the information health system is SIM or SINASC.

uf

an optional string or a vector of strings. By default all UFs ("Unidades Federativas") are download. See Details.

information_system

string. The abbreviation of the health information system to be accessed. See Details.

vars

an optional string or a vector of strings. By default, all variables read and stored, unless a list of desired variables is informed by this parameter.

stop_on_error

logical. If TRUE, the download process will be stopped if an error occurs.

timeout

numeric (seconds). Sets a timeout tolerance for downloads, usefull on large files and/or slow connections. Defaults to 240 seconds.

track_source

logical. If TRUE, adds a column called source with the downloaded file name.

Details

This function downloads DBC files from DataSUS following parameters about start date, end date, UF and health information system abbreviation. After the download process, the files are merged into a unique data.frame object.

A specific UF or a vector of UFs can be informed using the following abbreviations: "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO".

The following systems are implemented: "SIH-RD", "SIH-RJ", "SIH-SP", "SIH-ER", "SIM-DO", "SIM-DOFET", "SIM-DOEXT", "SIM-DOINF", "SIM-DOMAT", "SINASC", "CNES-LT", "CNES-ST", "CNES-DC", "CNES-EQ", "CNES-SR", "CNES-HB", "CNES-PF", "CNES-EP", "CNES-RC", "CNES-IN", "CNES-EE", "CNES-EF", "CNES-GM", "SIA-AB", "SIA-ABO", "SIA-ACF", "SIA-AD", "SIA-AN", "SIA-AM", "SIA-AQ", "SIA-AR", "SIA-ATD", "SIA-PA", "SIA-PS", "SIA-SAD", "SINAN-DENGUE-FINAL", "SINAN-DENGUE-PRELIMINAR", "SINAN-CHIKUNGUNYA-FINAL", "SINAN-CHIKUNGUNYA-PRELIMINAR", "SINAN-ZIKA-FINAL", "SINAN-ZIKA-PRELIMINAR", "SINAN-MALARIA-FINAL", "SINAN-MALARIA-PRELIMINAR".

Warning

A Internet connection is needed to use this function.

The year and month used to download the files regards the processing month and year of the cases by DataSUS.

The UF regards where the cases were processed by DataSUS.

The files are downloaded to a temporary folder and deleted after the reading process.

Examples

## Not run: 
fetch_datasus(year_start = 2010, year_end = 2011,
              information_system = "SIM-DO")

fetch_datasus(year_start = 2014, year_end = 2014,
              information_system = "SIM-DO",
              vars = c("CODMUNRES", "DTOBITO", "CAUSABAS"))

fetch_datasus(year_start = 2014, month_start = 1,
              year_end = 2014, month_end = 2,
              uf = c("RJ", "MG", "SP", "ES"),
              information_system = "SIH-RD")

## End(Not run)

rfsaldanha/microdatasus documentation built on April 13, 2024, 2:25 p.m.