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: Re: Using parent id variables in household data with Stata


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: Re: Using parent id variables in household data with Stata
Date   Mon, 26 Nov 2012 18:30:22 +0100

DELCLOS GOMEZ-MORAN, CARLOS-ERIC <[email protected]>:
Yes, I do--three different ways. You can adapt my example by repeating
the process, or you can use either of the other two methods I linked
to (explicit subscripting or merging)--did you read the material at
those links? The approach using repeated -merge-s is probably most
straightforward.

On Fri, Nov 23, 2012 at 8:08 PM, DELCLOS GOMEZ-MORAN, CARLOS-ERIC
<[email protected]> wrote:
> Thank you very much.  I've tried a similar logic, but actually, I do
> have mothers of mothers in there, and it does matter for my analysis.
> Do you know a good way to resolve that?
>
>
> 2012/11/23 Austin Nichols <[email protected]>:
>> DELCLOS GOMEZ-MORAN, CARLOS-ERIC <[email protected]>:
>> Are there mothers of mothers? Do you care if there are?
>> Might do something like this:
>>
>> clear
>> input year country houseid pid momid
>>      2007  0  600    60001   .
>>      2007  0  600    60002   .
>>      2007  0  600    60003   60001
>>      2008  0  600    60001   .
>>      2008  0  600    60002   .
>>      2008  0  600    60003   60001
>>      2008  0  600    60004   60001
>> end
>> bys year country houseid momid: g N=_N if !mi(momid)
>> g m=min(momid,pid)
>> bys year country houseid m (momid): g n=N[1] if mi(N)
>> list
>>
>> See also:
>> http://www.stata.com/support/faqs/data-management/creating-variables-recording-properties/
>> http://www.stata.com/statalist/archive/2006-06/msg00323.html
>>
>> On Fri, Nov 23, 2012 at 4:50 PM, DELCLOS GOMEZ-MORAN, CARLOS-ERIC
>> <[email protected]> wrote:
>>> Hello,
>>>
>>> I am trying to count the number of children a mother has in a household
>>> using the mother's id variable from the EU-SILC database.
>>>
>>> Basically, the data looks something like this:
>>>
>>> Year   country   houseid   pid         momid
>>> 2007   UK         600          60001     .
>>> 2007   UK         600          60002     .
>>> 2007   UK         600          60003     6001
>>> 2008   UK         600          60001     .
>>> 2008   UK         600          60002     .
>>> 2008   UK         600          60003     6001
>>> 2008   UK         600          60004     6001
>>>
>>>
>>> So what I'd like to do is create a variable with a value for the number of
>>> people (children) in the household who identify the person with that pid
>>> (in this case 60001) as their mother.  Is this possible with Stata, and if
>>> so, what is the best way to go about it?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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