Statalist The Stata Listserver


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

st: RE: Re: Filling gaps???


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: Filling gaps???
Date   Thu, 30 Nov 2006 16:33:32 -0000

Michael's one-liner solution is covered with a small mountain 
of commentary in 

2/03    How do I create a variable recording whether any
        members of a group (or all members of a group)
        possess some characteristic?
        http://www.stata.com/support/faqs/data/anyall.html

The FAQ also discusses the important issue raised by Austin
Nichols, what if missing values are present? 

Nick 
n.j.cox@durham.ac.uk 

Michael Blasnik
 
> I haven't seen any other one line solutions, so thought I'd 
> post as well:
> 
> by HouseholdID: egen HHinfected=max(Infected)
> 
> or, if there are no missing values in Infected:
> 
> by HouseholdID (Infected): gen byte HHinfected=Infected[_N]

Honorati Masanja
 
> > I have a dataset with individuals in households. Each 
> individual has a
> > unique identifier. Some individuals in the households are 
> infected and
> > some are not. My problem is how do I tell Stata to create a 
> new variable
> > which will have 1 for households with at least one infected 
> person  and
> > 0 for households without infected persons. The datasets 
> looks like this
> > 
> > HouseholdID  PersonID      Infected
> > 010101         01010101        1
> > 010101         01010102        1
> <snip>

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