[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Howard Lempel <HLempel@brookings.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Saving svy mean estimates? |

Date |
Tue, 7 Apr 2009 20:33:16 -0400 |

Rebecca, Following Joao's example, you may want to save your results in a matrix, which you can add to after you modify the data. Something like the following: *********begin example************* webuse highschool, clear svyset county [pweight=sampwgt], strata(state) vce(linearized) *Get mean for all students, by sex svy: mean weight, over(sex) *Store results in matrix named myresults matrix define myresults = e(b) *Get mean for black students gen black = race==2 svy, subpop(black): mean weight, over(sex) *Store results for black students as new row in my matrix matrix myresults = myresults\e(b) *Name the rows of my matrix mat rown myresults = total black matlist myresults *********end example************* Note that most people recommend that you use the -if- qualifier or -subpop- option to run commands on part of your dataset instead of -drop-ing anyone. If you want Stata to automatically make nice tables, you might want to look at Ben Jann's -estout- package (either the matrix mode or the -estpost- command using the -tabstat- option), which is available on SSC. This allows you to automat the creation of pretty tables but has a learning curve so is probably not worth it if you won't be using it a lot. Hope this helps. Howie -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Joao Ricardo F. Lima Sent: Tuesday, April 07, 2009 8:14 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Saving svy mean estimates? Rebecca, the svy mean estimates are saved in e(b) *********begin example************* webuse highschool, clear svyset county [pweight=sampwgt], strata(state) vce(linearized) svy: mean weight, over(sex) eret li mat li e(b) *********end example************* Sorry but I didn´t understand the second part of your question. HTH, Joao Lima 2009/4/7 Kanter, Rebecca <rkanter@jhsph.edu>: > Hi, > > I am using the svy mean command to calculate survey weighted state-specific mean estimates of different Mexican state characteristics, for example the percent of the population in a specific Mexican state that is indigenous > > Thus, I use the following command line: svy: mean indigena, over(state) > > And want to save these mean estimates (by state) as I would if I did an by state, sort: egen mean(indigena)--that was not accounting for the survey design; so my question is, how do I save the mean estimates by state from the above svy command line: svy: mean indigena, over(ent)?? And/or how do i save mean estimates for this that does take the svy pweight into account in the proper manner (if I can't do it with svy: mean)? [I want to then drop people from my dataset but want to have all the state estimates of characteristics saved as variables before doing so]. > > Thanks, > Rebecca > > > ___________________________________________ > Rebecca M. Kanter > PhD Candidate > Johns Hopkins Bloomberg School of Public Health > Department of International Health > Center for Human Nutrition > > * > * 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/ > -- ---------------------------------------- Joao Ricardo Lima, D.Sc. Professor UFPB-CCA-DCFS Fone: +5538387264913 Skype: joao_ricardo_lima ---------------------------------------- * * 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/ * * 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/

**References**:**st: Saving svy mean estimates?***From:*"Kanter, Rebecca" <rkanter@jhsph.edu>

**Re: st: Saving svy mean estimates?***From:*"Joao Ricardo F. Lima" <jricardofl@gmail.com>

- Prev by Date:
**RE: st: Saving svy mean estimates?** - Next by Date:
**Re: st: Saving svy mean estimates?** - Previous by thread:
**AW: st: Saving svy mean estimates?** - Next by thread:
**st: AW: Saving svy mean estimates?** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |