Statalist The Stata Listserver


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

Re: st: Filling gaps???


From   Philipp Rehm <Philipp.Rehm@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Filling gaps???
Date   Thu, 30 Nov 2006 14:03:52 +0100

input HouseholdID PersonID Infected
010101 01010101 1
010101 01010102 1
010102 01010201 0
010102 01010202 1
010102 01010203 1
010103 01010301 0
010103 01010302 0
010103 01010303 0
010104 01010401 0
010104 01010402 1
end

bys HouseholdID: egen InfectedHH=sum(Infected)
replace InfectedHH=1 if InfectedHH>=1 & InfectedHH<.

the variables "InfectedHH" is now a dummy equaling 1 if there is one or more infected person(s) in a household.

HTH,
Philipp

Honorati Masanja wrote:

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
010102         01010201        0
010102         01010202        1
010102         01010203        1
010103         01010301        0
010103         01010302        0
010103         01010303        0
010104         01010401        0
010104         01010402        1

Many thanks

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