Introduction to datasus

Renato Prado Siqueira

2018-05-15

A R Interface to the DATASUS’s data

The “datasus” R package seeks to provide direct access to the data of TABNET/DATASUS within the R environment much in the same way that is done in the online portal. For now the package allows access to the systematic record of mortality and survival data (Vital Statistics - Mortality and Live Births) through SIM and SINASC’s systems

Installation

To install the development version hosted on Github:

library(devtools)
install_github("rpradosiqueira/datasus")

Functions

The functions are named by parts:

Then, for example we have:

sinasc_nv_uf       Scrapes SINASC data from the states unities

sinasc_nv_mun      Scrapes SINASC data from municipalities
                   
sinasc_nv_bruf     Scrapes SINASC data from regions
                   
sim_obt10_uf       Scrapes SIM ICD-10 data from the states unities

sim_obt10_mun      Scrapes SIM ICD-10 data from cities

sim_obt10_bruf     Scrapes SIM ICD-10 data from regions

Examples

sinasc_nv_uf

  1. Let’s assume that we want the live births for the cities of the state of Mato Grosso do Sul. However, we will only recover the last five years and we want the cities to be in the rows and the years in the columns. To do this simply execute:
library(datasus)

sinasc_nv_uf(uf = "ms",
             periodo = c(2011:2015),
             coluna = "Ano do nascimento")
#>                          Município  2011  2012  2013  2014  2015  Total
#> 1                            TOTAL 42152 42252 42296 44058 44142 214900
#> 2                500020 Água Clara   283   263   278   247   253   1324
#> 3               500025 Alcinópolis    44    42    44    49    38    217
#> 4                   500060 Amambai   734   747   704   767   646   3598
#> 5                 500070 Anastácio   471   397   375   439   370   2052
#> 6              500080 Anaurilândia   111    95    99   108   118    531
#> 7                  500085 Angélica   137   168   155   157   170    787
#> 8              500090 Antônio João   170   156   175   165   146    812
#> 9      500100 Aparecida do Taboado   290   342   337   347   368   1684
#> 10               500110 Aquidauana   891   761   767   757   781   3957
#> 11             500124 Aral Moreira   150   167   172   159   148    796
#> 12             500150 Bandeirantes    69    90    81    90    74    404
#> 13               500190 Bataguassu   362   336   312   350   348   1708
#> 14                500200 Batayporã   191   151   162   171   167    842
#> 15               500210 Bela Vista   473   391   437   459   433   2193
#> 16                500215 Bodoquena   145    98   132   103   108    586
#> 17                   500220 Bonito   338   329   320   380   372   1739
#> 18              500230 Brasilândia   125   164   128   159   186    762
#> 19                  500240 Caarapó   536   453   504   539   545   2577
#> 20                  500260 Camapuã   174   194   194   213   213    988
#> 21             500270 Campo Grande 13045 13539 13693 14203 14470  68950
#> 22                  500280 Caracol    92    91    77    88    82    430
#> 23              500290 Cassilândia   265   281   278   290   292   1406
#> 24          500295 Chapadão do Sul   378   362   376   427   431   1974
#> 25                500310 Corguinho    44    48    37    39    36    204
#> 26         500315 Coronel Sapucaia   309   328   369   313   258   1577
#> 27                  500320 Corumbá  1996  1833  1982  2032  1979   9822
#> 28               500325 Costa Rica   338   391   369   391   455   1944
#> 29                    500330 Coxim   592   518   540   562   542   2754
#> 30               500345 Deodápolis   150   183   182   198   200    913
#> 31    500348 Dois Irmãos do Buriti   126   145   127   132   156    686
#> 32                500350 Douradina    84    84    83    76    79    406
#> 33                 500370 Dourados  3834  3694  3694  3784  3955  18961
#> 34                 500375 Eldorado   187   223   226   202   178   1016
#> 35            500380 Fátima do Sul   243   236   265   241   281   1266
#> 36                500390 Figueirão    36    37    36    51    56    216
#> 37       500400 Glória de Dourados   126   106   125   109   151    617
#> 38     500410 Guia Lopes da Laguna   217   169   141   168   134    829
#> 39                 500430 Iguatemi   246   232   236   252   236   1202
#> 40                500440 Inocência   115   113    96   111   140    575
#> 41                  500450 Itaporã   228   256   246   255   227   1212
#> 42                500460 Itaquiraí   242   228   229   271   279   1249
#> 43                 500470 Ivinhema   336   340   316   376   417   1785
#> 44                   500480 Japorã   198   184   197   185   205    969
#> 45                500490 Jaraguari    36    52    45    41    63    237
#> 46                   500500 Jardim   454   400   404   455   420   2133
#> 47                    500510 Jateí    74    50    73    46    49    292
#> 48                     500515 Juti    90    89   108   116    94    497
#> 49                  500520 Ladário   415   372   372   402   366   1927
#> 50            500525 Laguna Carapã   106   144   126   103   133    612
#> 51                 500540 Maracaju   613   644   638   714   719   3328
#> 52                  500560 Miranda   512   517   474   515   484   2502
#> 53               500568 Mundo Novo   276   271   295   296   290   1428
#> 54                  500570 Naviraí   839   901   867   941   962   4510
#> 55                  500580 Nioaque   153   172   168   194   191    878
#> 56     500600 Nova Alvorada do Sul   311   351   329   363   308   1662
#> 57           500620 Nova Andradina   721   777   673   790   847   3808
#> 58    500625 Novo Horizonte do Sul    71    72    74   103    86    406
#> 59        500627 Paraíso das Águas    NA    NA    31    31    39    101
#> 60                500630 Paranaíba   523   587   526   582   555   2773
#> 61                 500635 Paranhos   352   359   350   325   294   1680
#> 62              500640 Pedro Gomes   100    89   104    89    81    463
#> 63               500660 Ponta Porã  1807  1795  1610  1620  1552   8384
#> 64           500690 Porto Murtinho   272   281   255   256   208   1272
#> 65       500710 Ribas do Rio Pardo   330   376   344   360   369   1779
#> 66            500720 Rio Brilhante   611   637   648   705   684   3285
#> 67                500730 Rio Negro    70    45    57    40    43    255
#> 68 500740 Rio Verde de Mato Grosso   288   278   272   259   341   1438
#> 69                  500750 Rochedo    58    67    37    54    42    258
#> 70      500755 Santa Rita do Pardo    97   105    75    80    60    417
#> 71     500769 São Gabriel do Oeste   374   408   412   458   538   2190
#> 72                 500780 Selvíria    61    46    58    70    80    315
#> 73              500770 Sete Quedas   183   180   153   128   134    778
#> 74              500790 Sidrolândia   686   656   671   697   683   3393
#> 75                   500793 Sonora   281   252   287   254   239   1313
#> 76                   500795 Tacuru   225   221   225   222   231   1124
#> 77               500797 Taquarussu    51    46    50    51    39    237
#> 78                  500800 Terenos   155   168   175   176   170    844
#> 79              500830 Três Lagoas  1769  1804  1952  2033  1953   9511
#> 80                500840 Vicentina    67    75    62    74    72    350

sim_obt10_mun

  1. In this example we will download the last mortality data for the IBGE’s micro-region where the micro-regions are in the rows and the ICD-10 chapters in the columns (only 10 rows):
sim_obt10_mun(linha = "Microrregião IBGE",
              coluna = "Capítulo CID-10")
#>        Microrregião IBGE Cap I Cap II Cap III Cap IV Cap V Cap VI Cap VII
#> 1                  TOTAL 57188 215217    6878  78075 12674  36870      20
#> 2      11001 Porto Velho   207    474      14    118    18     50      NA
#> 3    11002 Guajará-Mirim    20     39       2     25    NA      5       1
#> 4        11003 Ariquemes    36    116       4     47     2     14      NA
#> 5        11004 Ji-Paraná    66    218      14    131     9     28      NA
#> 6 11005 Alvorada D'Oeste     5     45      NA     29    NA      5      NA
#>   Cap VIII Cap IX  Cap X Cap XI Cap XII Cap XIII Cap XIV Cap XV Cap XVI
#> 1      173 362091 158041  66044    5874     5787   39367   1814   21049
#> 2        1    553    284    139       4       17      98      9      81
#> 3       NA     71     33     18      NA       NA      10     NA      10
#> 4       NA    216     87     32       2        2      27      3      23
#> 5       NA    446    164     85       4        1      58     NA      22
#> 6       NA    102     28     14       1        2       8      1       3
#>   Cap XVII Cap XVIII Cap XX   Total
#> 1    10882     75869 155861 1309774
#> 2       47       203    592    2909
#> 3       10        25     47     316
#> 4       17        62    194     884
#> 5       19        76    239    1580
#> 6        3        20     74     340

And so on…

The argument’s input is written in the same way that is done in the online portal or in some cases it can be the order of the input according to the online layout.

Online access for mortality data by municipality: