DELCLOS GOMEZ-MORAN, CARLOS-ERIC <carloseric.delclos@upf.edu>:
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
<carloseric.delclos@upf.edu> 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 <austinnichols@gmail.com>:
>> DELCLOS GOMEZ-MORAN, CARLOS-ERIC <carloseric.delclos@upf.edu>:
>> 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
>> <carloseric.delclos@upf.edu> 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/