Statalist The Stata Listserver


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

Re: st: identify strata with one distinct value of psu


From   "Austin Nichols" <[email protected]>
To   [email protected], "Brent Fulton" <[email protected]>
Subject   Re: st: identify strata with one distinct value of psu
Date   Mon, 18 Dec 2006 14:21:17 -0500

All--
Sorry, for "$y $x" read "loglead sizp" in my example, or try:

webuse nhanes2, clear
replace sizp=. if psu==2 & str>10
global y loglead
global x sizp
svydes $y $x, gen(notok)
tab stra notok
egen not=max(notok), by(strat)
g ok=1-not
tab stra ok
qui reg $y $x if !mi(weight,psu,strata)
g new_psu=psu if e(sample)
egen sd_psu=sd(new_psu), by(strata)
qui levelsof strata if sd_psu>0, local(ok)
di "`ok'"
local oklist: subinstr loc ok " " ",", all
di "`oklist'"
g sok=inlist(strata,`oklist')
tab ok sok
svy, subpop(ok): reg $y $x


PS. Brent, you can also
set trace on
set traced 1
to see how locals and globals are evaluated by Stata... a very useful
pair of commands for many purposes, in fact.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index