Statalist


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

Re: st: need help with svymean


From   Deepankar Basu <basu.15@osu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: need help with svymean
Date   Thu, 29 Nov 2007 18:02:18 -0500

Please ignore the earlier message; there was an error in the code.

Deepankar

On Thu, 2007-11-29 at 14:55 -0500, DEEPANKAR BASU wrote:
> 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/

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