Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: creating variable from svy: proportion

 From Steve Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: creating variable from svy: proportion Date Mon, 3 May 2010 16:38:14 -0400

```For the analyses you have described so far, you have, in effect,
defined a new  "population" that consists only of the cooperatives
that were selected at the first stage. For analyzing this
"population", the original suggestions I made were incorrect. Here are
my revised suggestions.

You should declare cooperative as the new "stratum" and  redefine the
design as two-stage, not three-stage.  You should also not use the
-over- option. That assumes that the coops in the are random and will
calculate standard errors and degrees of freedom incorrectly.

Whether and how to set the finite population correction for the
popcode selection stage will depend  on how the popcodes and
individuals were selected. Were the probabilities of selection of
popcodes the same within a coop?  If so, specify the fpc to be that
fraction, say f1, , and ignore fpc's at the stage of individual
selection. If the probabilities were not constant, then do not specify
the fpc.

So here's my suggested code for the analysis of the sampled coops only:

svyset popcode [pw= new_pw], strata(dccode) fpc(f1)

To calculate proportions and totals, then:

levelsof dccode, local(levels)
foreach l of local levels {
di "dccode = `i'"
svy: prop isb17 if l ==`i', se ci
}
foreach l of local levels {
di "dccode = `i'"
svy: total isb32a if l ==`i'
}

I'm curious: I assume that you are also doing analyses to describe the
entire population.  What's your purpose in doing these analyses that
describe only the cooperatives in the sample?

Steve

On Mon, May 3, 2010 at 3:46 PM, Guy Grossman <guygrossman1@gmail.com> wrote:
> Dear Steve -
>
> Thanks a million for the note. One last question which I hope
> finalizes the thread. I also need to calculate totals at the
> cooperative level for continuous variable isb32a. following your
> advice I set the design to reflect only the prob of selecting ind X
> prob of selecting a group.
>
> new_pw = (1/prob sel pocode) x (1/ prob sel individual).
> svyset dccode [pw= new_pw], strata (strata) fpc(fpc1) || pocode,
> fpc(npos) || _n fpc(popop)
>
> Howeve when I run the svy: total command I get the following error message:
> svy: total isb32a , over(dccode)
> (running total on estimation sample)
>
> fpc for all observations within a stratum must be the same
> r(461);
>
> any idea how to fix the error?
> Again, many thanks to all those contributing to the thread!
>
> Guy
> *
>

--
Steven Samuels
sjsamuels@gmail.com
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```