The CNES (Cadastro Nacional de Estabelecimentos de Saude) is Brazil’s national health facility registry, maintained by the Ministry of Health through DATASUS. It contains monthly snapshots of all registered health establishments, professionals, beds, equipment, and more.
The healthbR package provides access to CNES data from
the DATASUS FTP:
| Feature | Details |
|---|---|
| File types | 13 (establishments, beds, professionals, etc.) |
| Frequency | Monthly (one file per type/UF/month) |
| Years | 2005–2024 (final + preliminary) |
| Coverage | Per state (27 UFs) |
| Format | .dbc files, decompressed internally |
CNES data is organized into 13 file types:
| Code | Name | Description |
|---|---|---|
| ST | Estabelecimentos | Health facility registry (default) |
| LT | Leitos | Hospital beds |
| PF | Profissional | Health professionals |
| DC | Dados Complementares | Supplementary facility data |
| EQ | Equipamentos | Health equipment |
| SR | Servico Especializado | Specialized services |
| HB | Habilitacao | Facility accreditations |
| EP | Equipes | Health teams |
| RC | Regra Contratual | Contractual rules |
| IN | Incentivos | Financial incentives |
| EE | Estab. de Ensino | Teaching facilities |
| EF | Estab. Filantropico | Philanthropic facilities |
| GM | Gestao e Metas | Management and targets |
The month parameter controls which monthly snapshots to
download:
# single month
jan <- cnes_data(year = 2023, month = 1, uf = "AC")
# first semester
sem1 <- cnes_data(year = 2023, month = 1:6, uf = "AC")
# specific months
q1_q3 <- cnes_data(year = 2023, month = c(3, 6, 9), uf = "AC")
# all 12 months (default when month = NULL)
full_year <- cnes_data(year = 2023, uf = "AC")| Variable | Description |
|---|---|
| CNES | Facility CNES code |
| CODUFMUN | Municipality (UF + IBGE 6 digits) |
| TP_UNID | Facility type (22 categories) |
| VINC_SUS | SUS-linked (0=No, 1=Yes) |
| TP_GESTAO | Management type (M=Municipal, E=State, D=Dual) |
| ESFERA_A | Administrative sphere (1=Federal, 2=State, 3=Municipal, 4=Private) |
| TURNO_AT | Operating hours |
| NIV_HIER | Hierarchy level |
| ATV_AMBUL | Outpatient care (0/1) |
| ATV_HOSP | Hospital care (0/1) |
| ATV_URG | Emergency care (0/1) |
| COMPETEN | Reference period (YYYYMM) |
# get facility type labels
tp_unid_labels <- cnes_dictionary("TP_UNID") |>
select(code, label)
# join to data
ac_facilities <- cnes_data(year = 2023, month = 1, uf = "AC") |>
left_join(tp_unid_labels, by = c("TP_UNID" = "code")) |>
rename(facility_type = label)
ac_facilities |>
count(facility_type, sort = TRUE)Combine CNES bed data with Census population:
# step 1: count beds by UF (December snapshot)
beds <- cnes_data(year = 2023, month = 12, type = "LT") |>
group_by(uf_source) |>
summarize(total_beds = n(), .groups = "drop")
# step 2: population from Census 2022
pop <- censo_populacao(year = 2022, territorial_level = "state")
# step 3: calculate beds per 1,000 inhabitants
# beds_rate <- beds |>
# left_join(pop, by = ...) |>
# mutate(beds_per_1000 = (total_beds / population) * 1000) |>
# arrange(desc(beds_per_1000))# quarterly snapshots for Sao Paulo
sp_quarterly <- cnes_data(
year = 2020:2023,
month = c(3, 6, 9, 12),
uf = "SP"
)
facility_trend <- sp_quarterly |>
group_by(year, month) |>
summarize(
total = n(),
sus_linked = sum(VINC_SUS == "1", na.rm = TRUE),
.groups = "drop"
) |>
arrange(year, month)
facility_trendCNES data is monthly and per-state, so full downloads can involve many files:
Use uf and month to limit downloads. Start
with a single UF and month to explore the data before scaling up.
Downloaded data is cached locally for faster future access:
If the arrow package is installed, data is cached in
Parquet format. You can also use lazy evaluation:
cnes.datasus.gov.br)dados.gov.br)