Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Single PSU - problem with SVYDES to estimate variance


From   "Patrick Wöhrle Guimarães" <probabilidade@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Single PSU - problem with SVYDES to estimate variance
Date   Sat, 3 Mar 2007 20:38:51 -0300

 Im working with complex design and I have stratum with Single PSU
because this - I need to solve this problem for estimate variance. My
first step is:

svyset psu [pweight=peso], strata(strat) (define complex design)
svydes rendapc2, single

 With this information - I have a ado-file to agregate stratum with
single psu in stratum with more high observation in the same State (or
next). My problem is that the SVYDES doesn´t find one stratum that has
a single psu (in the list the stratum that has single psu only this
stratum doesnt appear (the number 53) -  I dont know why?).
 In my ado-file:

rendapc2 = personal income per capita

MY ADO-FILE:

* ROTINA DE ALOCACAO DE ESTRATOS COM UM UNICO PSU EM ESTRATOS COM MAIOR NUMERO
* DE OBSERVACOES UTILIZANDO O DO.FILE idonepsu rendapc - PARA A
VARIAVEL RENDPC2 - ANO DE  2005


use "C:\DATA\PNAD\PNAD2005\pes2005.dta", clear
keep if uf < 11
gene novo_str = .
gene novo_psu = .
format novo_psu %12.0g
save "C:\DATA\PNAD\PNAD2005\acum.dta",replace

capture program drop prog1
program define prog1
use "c:\DATA\PNAD\PNAD2005\pes2005.dta", clear
keep if uf == estado
gene novo_str = strat
gene novo_psu = psu
quietly {
save "c:\DATA\PNAD\PNAD2005\transf.dta",replace
use "c:\DATA\PNAD\PNAD2005\acum.dta", clear
append using "c:\DATA\PNAD\PNAD2005\transf.dta"
save "c:\DATA\PNAD\PNAD2005\acum.dta",replace
}
end

capture program drop prog2
program define prog2
use "c:\DATA\PNAD\PNAD2005\pes2005.dta", clear
keep if uf == estado
idonepsu rendapc2 , generate(novo_) strata(strat)  psu(psu)
quietly {
save "c:\DATA\PNAD\PNAD2005\transf.dta",replace
use "c:\DATA\PNAD\PNAD2005\acum.dta", clear
append using "c:\DATA\PNAD\PNAD2005\transf.dta"
save "c:\DATA\PNAD\PNAD2005\acum.dta",replace
}
end

scalar estado = .


*foreach i in 53   {
*     scalar estado = `i'
*     prog1
*}

foreach i in 11 12 13 14 15 16 17 21 22 23 24 25 26 27 28 29 31 32 33
35 41 42 43 50 51 52 53  {
    scalar estado = `i'
    prog2
}


drop strat psu
rename novo_str strat
rename novo_psu psu

svyset [pw=peso], strata(strat) psu(psu)


save "c:\DATA\PNAD\PNAD2005\pes2005_rendapc2.dta", replace


--

Patrick

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index