Statalist The Stata Listserver

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

st: Re: Filling gaps???

From   "Michael Blasnik" <>
To   <>
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" <>
To: <>
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
*   For searches and help try:

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