Statalist The Stata Listserver


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

st: Re: Filling gaps???


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Filling gaps???
Date   Thu, 30 Nov 2006 08:29:11 -0500

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]

Michael Blasnik

----- Original Message ----- From: "Honorati Masanja" <honorati.masanja@unibas.ch>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, November 29, 2006 5:07 PM
Subject: st: Filling gaps???



Dear all

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