Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: RE: count number of working adult

From   Nick Cox <>
To   "" <>
Subject   Re: st: RE: count number of working adult
Date   Fri, 21 Jun 2013 23:42:55 +0100

I think Elan is correct here. Looping is the best strategy for your
wide data structure.

There is more detail within


On 21 June 2013 21:10, Cohen, Elan <> wrote:

> I can't think of a way without looping.  Maybe someone else can.
> g numadultwork = 0
> forv i=1/11 {
>   replace numadultwork = numadultwork + (age`i'>17 & !mi(age`i'))*(working`i'==1)
> }

Shikha Sinha

> Thanks Elan. I can get it work in the long version of the data, but
> was wondering about the ways to do it in the WIDE format. I can go
> back and forth from wide-long-wide, but in general I am interested in
> getting "working adult' in the wide format in Stata.

Elan Cohen

>> reshape long person age working, i(hhid) j(personid)
>> egen numadultwork = sum((work==1)*(age>17 & !mi(age))), by(hhid)
>> * Assuming you want to go back to wide format (though I don't see why):
>> reshape wide person age working, i(hhid) j(personid)

Shikha Sinha

>> I want to estimate how many working adults are in each household. The
>> data is in wide format. Adult is defined as age >17 and working info
>> is coded as 1/0.
>> hhid peson1-person11  age1-age11 working1-working11
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index