DOI: 10.7910/dvn/km3g1o
title: Pesquisa Nacional Por Amostra De Domicilios (PNAD)

description: &lt;h3 class="post-title entry-title" itemprop="name"&gt; analyze the pesquisa nacional por amostra de domicilios (pnad) with r &lt;/h3&gt; think of the pesquisa nacional por amostra de domicilios (pnad) as the brazilian census for off-years - the ones that don't end in zero. the principal household survey for the nation of brazil, pnad measures general education, labor, income, and housing characteristics of the population. pesquisa nacional por amostra de domicilios translates to 'national household sa
mple survey' and, like most things, sounds better in the native portuguese
&lt;a href="http://www.ibge.gov.br/english/presidencia/noticias/noticia_visualiza.php?id_noticia=2346&amp;id_pagina=1"&gt;(exhibit a)&lt;/a&gt;. my first foray into survey data for a country outside of the united states, this comes at the request of &lt;a href="mailto:djalma.pessoa@ibge.gov.br"&gt;djalma pessoa&lt;/a&gt; who co-authored both this post and the published scripts. djalma works as a consultant for the office in charge of statistical survey methodology at &lt;a href="http://www.ibge.gov.br/english/"&gt;the braz
ilian institute of geography and statistics (ibge)&lt;/a&gt;, just like a united states census bureau headquartered in rio de janeiro.&lt;br /&gt; &lt;br /&gt; pnad has been on the shelves for forty-four years, investigating all the good stuff: migration, fertility, marriage, health, and food security. &lt;a href="ftp://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/microdados/"&gt;microdata are available back to 2001&lt;/a&gt; and starting in 2004, pnad started including the rural n
orth (the amazon state, among others). the sample design is self-weighted with three selection stages: primary sampling units are municipalities stratified by population size, selected systematically with pps. secondary and tertiary sampling units are enumeration areas, then households. the weights also need to be post-stratified to the 2010 official brazilian census. all in all, a pretty straightforward methodology. let the code do all the setup for you so you can worry about the more exciting questions and then clock out for the day. by the way, in brazil, do they call happy hour
&lt;a href="http://en.wikipedia.org/wiki/Caipirinha"&gt;cappy&lt;/a&gt; hour? this new github repository contains four scripts:&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;b&gt;2001-2011 - download all microdata.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;download the fixed-width file containing household and person records&lt;/li&gt; &lt;li&gt;merge 'em together into a rectangular file at the person-level&lt;/li&gt; &lt;li&gt;create an adjusted weight and a new variable - one - in the data table&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;2011 single-year - analysis examples.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;con
nect to the sql database created by the 'download all microdata' program
&lt;/li&gt; &lt;li&gt;create the complex sample survey object, post-stratifying using a custom-built function&lt;/li&gt; &lt;li&gt;perform a boatload of analysis examples&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;&lt;b&gt;2011 single-year - variable recode example.R&lt;/b&gt;&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;connect to the sql database created by the 'download all microdata' program&lt;/li&gt; &lt;li&gt;recode some numeric variables into a broader categorical variable &lt;/li&gt; &lt;li&gt;re-create the complex sample survey object, post-stratifying using a custom-built function&lt;/li&gt; &lt;/ul
&gt; &lt;br /&gt; &lt;b&gt;replicate IBGE estimates - 2011.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;connect to the sql database created by the 'download all microdata' program&lt;/li&gt; &lt;li&gt;create the complex sample survey object, post-stratifying using a custom-built function&lt;/li&gt; &lt;li&gt;precisely match the sas-sudaan output provided by analysts at ibge (as seen in the script directory)&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;br /&gt; &lt;a href="https://github.com/ajdamico/usgsd/tree/master/Pesquisa%20Nacional%20por%20Amostra%20de%20Domicilios"&gt;click here to vie
w these four scripts&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; for more detail about the annual pesquisa naciona por amostra de domicilios, visit:&lt;br /&gt; &lt;ul&gt; &lt;li&gt;the official brazilian statistics agency's homepage (&lt;a href="http://www.ibge.gov.br/english/"&gt;english&lt;/a&gt;) (&lt;a href="http://www.ibge.gov.br/home/"&gt;portuguese&lt;/a&gt;) (even &lt;a href="http://www.ibge.gov.br/espanhol/"&gt;espanhol&lt;/a&gt;)&lt;/li&gt; &lt;li&gt;&lt;a href="ftp://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/"&gt;the ibge
ftp site with all your favorite microdatos&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.blogger.com/translate.google.com/translate?hl=en&amp;sl=pt&amp;tl=en&amp;u=http://pt.wikipedia.org/wiki/Pesquisa_Nacional_por_Amostra_de_Domic%25C3%25ADlios"&gt;the translated-into-english pnad wikipedia entry&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; notes: &lt;br /&gt; &lt;br /&gt; to accommodate smaller computer workstations (with only 4gb of ram), these scripts perform all manipulations inside sqlite and rely on &lt;a href="http://faculty.washington.edu
/tlumley/survey/svy-dbi.html"&gt;database-backed survey objects&lt;/a&gt;. &lt;a href="http://faculty.washington.edu/tlumley/survey/html/postStratify.html"&gt;the post-stratification function&lt;/a&gt; in the current implementation of the r survey package does not work on database-backed survey design objects. therefore, with little fanfare, i've written one that does. you'll find it getting pulled in at the source_url() line. exciting.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; confidential to sas, spss, stata, sudaan users: yes, and
bicycles with training wheels might be easier to ride, but that doesn't make them a long-term solution. time to transition to r. :D