Statalist


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

st: need help with svymean


From   DEEPANKAR BASU <basu.15@osu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: need help with svymean
Date   Thu, 29 Nov 2007 14:55:37 -0500

I am working with survey data on Stata 8. In the dataset observations are by family and I have complete birth history for each family. I want to compute the sex ratio at birth for a chosen cohort.



/*------ DETAILS OF SURVEY DESIGN---------*/
gen strat = v022 
gen psuid = v021 
gen smpwt = v005/1000000
svyset [pweight=smpwt], strata(strat) psu(psuid) 


/* yob1 gives the year of birth for child 1 */
/* yob2 gives the year of birth for child 2 */
/* ------------------------------------ */
/* yob18 gives the year of birth for child 18 */

/* - CREATING THE BIRTH COHORT: 1995-20 - */
gen id = _n
reshape long yob, i(id) j(birth)
drop if yob<1995
drop if yob>2000
reshape wide

/* ---------------------------------------- */
/* GETTING SEX OF CHILD: MALE=1; FEMALE=0    */
/* sxch1 gives the sex of child 1; and so on... */
 forval i=1/18 {
   quietly gen sxch`i'= cord`i'-2 if cord`i'==2
   quietly replace sxch`i'= cord`i' if cord`i'==1
 }


reshape long sxch, i(id) j(birth)
svymean sxch

I get the error message "no observations" after the last command. What am I missing?

Thanks.

Deepankar 

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