Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: repeating the same analysis for each stratum


From   Phung Lang <plang@ifspm.unizh.ch>
To   statalist@hsphsun2.harvard.edu
Subject   st: RE: RE: RE: repeating the same analysis for each stratum
Date   Wed, 30 Jul 2003 16:54:35 +0200

Many thanks to Thi Minh, Carrie and Bryan for their helpful comments.  I
tried to run the short program TM suggested, but found that it does not
work for all 26 strata.  It does the analysis for only one stratum and then
stops, saying that there are no more observations in the database or a
certain variable cannot be found (which is not originally in the database).
Is it suppose to loop, so that the analysis is repeated for each of the 26
stratum? If not, how can it be corrected so that it will loop 26 times, for
each stratum?

Here are my survey settings:
pweight is fwtia
strata is kt
psu is cluster

and the program:

forvalues k= 1(1) 26 {
  drop if kt~=`k'
  do test.do
  }

After running the analysis for the first stratum, then it reads:

end of do-file
(572 observations deleted) ORIGINALLY THERE ARE 11,936 OBSERVATIONS

It then tries to repeat the analysis for the next stratum, and:

. version 7.0

. xi: svylogit shotdi4 i.meduc, or
variable __0000KL not found  (I DO NOT HAVE THIS VARIABLE IN THE DATABASE)



Any idea how to fix this? Once more, thank you for your help in advance.

Phung



Date: Tue, 29 Jul 2003 12:38:22 +0100
From: "Ngo,PT  (pgr)" <P.T.Ngo@lse.ac.uk>
Subject: st: RE: repeating the same analysis for each stratum

Hello Phung,

Would this work ? keep only the data for each stratum, and call your do file.
svyset, clear allows to clear the survey variable which I suppose you have
specified in your main analysis.do file.

forvalues k = 1 (1) 26 {
	drop if strata~=`k'
	svyset, clear
	do analysis.do
	}

Thi Minh Ngo

Date: Tue, 29 Jul 2003 13:44:21 +0200
From: Phung Lang <plang@ifspm.unizh.ch>
Subject: st: repeating the same analysis for each stratum

Dear Statalist

I have a database for a complex survey with 26 strata and 100 PSUs. I have
done the analysis using the svy components for the entire database, and now
would like to repeat the same analysis for each of the 26 strata. The
planned analysis is already a do.file. I have not been able to figure out
how run this do.file for each stratum efficiently as I am not a programmer.
I have tried "by", but it does not work with the svymean or do command. Can
someone give me some advice?  I am using stata 7.0.

Gratefully yours,
Phung



Institute for Social and Preventive Medicine (ISPM)
at the University of Zurich
Sumatrastrasse 30
CH-8006 Zurich, Switzerland

Tel: +41-1-634 46 72 /13
Fax: +41-1-634 49 84
email: plang@ifspm.unizh.ch


*
*   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