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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: RE: Re: percent of time a |

Date |
Wed, 11 Feb 2009 20:40:37 -0000 |

I've not tried understanding this but my guess is that -collapse- on an indicator and whatever -by()- you want would get you there with less pain. Nick n.j.cox@durham.ac.uk Howard Lempel It would have been helpful if I'd been more explicit. I have various income variables that are topcoded and censored at zero and would like to know how often that bites among many different subpopulations. The censoring means that p(X_i=0) is not zero. I guess it's also true that my variables are not strictly continuous in that they're rounded to the nearest integer. I ended up doing something like the following: Gen zero = . foreach var in `vars' { local rowcount = 1 foreach gend in `genders' { foreach yr in `yrs' { local colcount = 1 *Do other things . . . . . . *Find out how often my variable is zero replace zero = (`var'==0) sum zero [aw=wgt] if gender==`gend' & year==`yr', meanonly matrix `var'mat[`rowcount', `colcount'] = r(mean) local colcount = `colcount' + 1 *Do more other things . . . . . . } } } Nick's method using the _gwtmean function for -egen- also works, but since there's no -ereplace- function, it would have involved either -dropping- a variable in each iteration of the loop, or -egenerating- lots of variables. * * 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: Re: percent of time a***From:*Kit Baum <baum@bc.edu>

**st: RE: Re: percent of time a***From:*Howard Lempel <HLempel@brookings.edu>

- Prev by Date:
**Re: st: Mata st_store problem with selectvar (using mm_root)** - Next by Date:
**RE: st: Fixing the value in egen command** - Previous by thread:
**st: RE: Re: percent of time a** - Next by thread:
**st: Re: percent of time a** - Index(es):

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