Gisella Young <[email protected]>:
This is part of a FAQ.
g long hhid=sum(person==1)
should do it. See also
http://www.stata.com/support/faqs/data/members.html
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004
On Mon, Apr 21, 2008 at 7:21 AM, Gisella Young <[email protected]> wrote:
> Dear Statalisters,
>
> I have a simple question. I am working with a household dataset in which the households are not coded as such but are evident from the individual numbers. It is set up as follows:
>
> PERSON VAR1 VAR2 ...
> 1
> 2
> 3
> 1
> 1
> 2
> ....
>
> (I haven't filled in the variables above).
>
> The 'person' data actually refers to the person's household membership ie household one has 3 members, houshold 2 has 1 member, household 3 has 2
> members, etc. I would like to create a new variable 'household', in which each household has a unique number as follows:
>
> HOUSEHOLD PERSON VAR1 VAR2 ...
> 1 1
> 1 2
> 1 3
> 2 1
> 3 1
> 3 2
> ....
>
> (Then if I concatenate 'household' and 'person' each individual will have a uniqe number.)
>
> Any suggestions as to how to create the household variable?
>
> Thank you!
>
> Gisella
*
* 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/