Bookmark and Share

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


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

Re: st: Identifying subfamilies (2nd+ marriages) within records of families


From   Anna Reimondos <[email protected]>
To   [email protected]
Subject   Re: st: Identifying subfamilies (2nd+ marriages) within records of families
Date   Thu, 2 Feb 2012 10:26:39 +1100

Thanks Nick- that worked perfectly!!
Much appreciated,
Anna

On Thu, Feb 2, 2012 at 10:10 AM, Nick Cox <[email protected]> wrote:
> Blonde moment!!!
>
> Sounds like
>
> bysort family (reg) : gen familynum = sum(reg != reg[_n-1]) - 1
>
> With this definition, I am assuming that -family- is string (else how
> can a value be empty?) and  the wife herself is labelled 0.
>
> There would be a small tweak  needed if -family- were really numeric.
>
> Nick
>
> On Wed, Feb 1, 2012 at 10:53 PM, Anna Reimondos <[email protected]> wrote:
>
>> I have a dataset of families which looks something like this:
>>
>> The first variable is a family id, then there is a registration
>> number, and a variable identifying whether the person is the wife,
>> husband or child.
>> In the example below there are two families. In the first family there
>> is a wife, husband and kids. In the second family the woman has had 2
>> marriages. In the first she had 2 children, and in the second marriage
>> she had one child. What I would like to do is create a variable called
>> 'familynum' which will number the different families within the main
>> family.
>>
>> NB: There is no registration or familynum for the woman.
>>
>>     family   reg        person        familynum
>>        1                       Wife    (1)
>>        1       693             Husband(2)      1
>>        1       693             Child   (3)             1
>>        1       693             Child   (3)             1
>>        2                       Wife    (1)
>>        2       542             Husband(2)      1
>>        2       542             Child   (3)             1
>>        2       542             Child   (3)             1
>>        2       879             Husband(2)      2
>>        2       879             Child   (3)             2
>>
>>
>> I have done similar things before, and I know the solution is probably
>> very obvious...but I am having a blonde moment.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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