Statalist The Stata Listserver


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

Re: st: combining multiple years of data, take two...


From   jpitblado@stata.com (Jeff Pitblado, StataCorp LP)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: combining multiple years of data, take two...
Date   Sun, 27 May 2007 23:48:38 -0500

Eleanor Friedman <nora@uchicago.edu> is working with survey data from
multipler years:

> I wrote earlier this year about how to svyset a data set
> involving multiple years of data from the CDC's BRFSS survey.
> I got a response (posted below) for what to do. This seemed to
> work fine, but now when I try to do a regression using
> svyregress, I get an error message saying "data not set up for
> svy, use survey set." any ideas what could be wrong? 

> > Eleanor Friedman <nora@uchicago.edu> asks for the Stata
> > equivalent of using the PSULEV option in SUDAAN's NEST statement:
> > 
> > In the SUDANN line
> > 
> > 	NEST SURVYEAR _STSTR_PSU PSULEV=3;
> > 
> > the 'PSULEV=3' option identifies the position of the PSU
> > (primary sampling unit) variable in the NEST statement.  This
> > means that all other variables to the left of this position
> > identify the strata in the first stage.  Eleanor's
> > example only specifies 2 variables, so this means that the
> > 'SURVYEAR' and '_STSTR_PSU' variables identify the first stage
> > strata.
> > 
> > Although Stata's -svyset- command allows only one variable in
> > the -strata()- option for each sampling stage, Eleanor can use
> > -egen- with the -group()-function to generate a single strata
> > variable for use with -svyset- in this case.
> > 
> > Assuming Eleanor only has information for the first stage and
> > the weight variable (in her Stata dataset) is named
> > SAMPWEIGHT, she can do the following:
> > 
> > 	. egen STRATA1 = group(SURVYEAR _STSTR_PSU)
> > 	. svyset _n [pw=SAMPWEIGHT], strata(STRATA1)
> > 
> > I would also suggest that Eleanor save this modified dataset
> > under a new name,such as
> > 
> > 	. save mybrfss
> > 
> > Then Eleanor can use this new 'mybrfss.dta' Stata dataset in
> > the future without having to worry about the survey design
> > variables since the -svyset- information is saved with the
> > data in 'mybrfss.dta'

It appears that Eleanor is trying to use -svyregress- with modern survey
characteristics from the new and improved -svyset- command in Stata 9.

-svyregress- was replaced by -svy: regress- in Stata 9.

-svyregress- continues to work, but only with the older version of survey
design characteristics.  If Eleanor wishes to continue using -svyregress-,
she can -svyset- her dataset's design characteristics under version control
(and using the -svyset- syntax prior to Stata 9).

	. version 8: svyset [pw=SAMPWEIGTH], strata(STRATA1)

--Jeff
jpitblado@stata.com
*
*   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