3
When reading the Pnad 2016, I executed the code below, in r studio
# Ler o dicionário de variáveis com as posições
#devtools::install_github("tidyverse/readr")
library(readxl)
library(dplyr)
library(readr)
dic = read_xls("dicionario_das_variaveis_PNAD_Continua_microdados.xls",
skip=4,
col_names = F)
dic = dic %>% select(1:3) %>% na.omit
dic$inicio = as.integer(dic$inicio)
names(dic) = c("inicio", "tamanho", "nome")
dic
# Lendo a PNAD
# Primeiro, vamos definir um objeto com o formato das variáveis de interesse
?read_fwf
posicoes = fwf_positions(start = dic$inicio, end = dic$inicio + (dic$tamanho - 1),
col_names = dic$nome)
posicoes$begin = posicoes$begin + 1
pnad16.1 = read_fwf("PNADC_012016_20180816.txt", col_positions = posicoes)
But in the end, the program does not run and presents the error:
Error in guess_types_(datasource, tokenizer, locale, n = guess_max) :
Begin offset (5) must be smaller than end offset (5)
I appreciate help!!
Danielle, the dictionary you are using may not be from this PNAD report. Try downloading the dictionary from the same address you downloaded Pnad. https://servicodados.ibge.gov.br/download/DownloadArvore.aspx?f=1&camio=Trabalho_e_Rendimento/Pesquisa_nacional_por_amostra_de_domicilios_continua/Trimestral/Microdados/2016
– Daniel Ikenaga