HI Steven:
Your suggestion worked fine, and it is much faster than the way I was
doing it.
Thanks,
Juan
> Sorry, there was a mistake in this suggestion: it should read "change the
> id
> variable from id to p_id1" not the other way around. Steve
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Steven
> Stillman
> Sent: Thursday, December 01, 2005 1:37 AM
> To: [email protected]
> Subject: st: RE: Creation of family id
>
>
> Hi Juan. One way to do this is to create X copies of your data set. Copy
> 1
> is your root copy. Open copy 2 and pre/post-fix all variables with say
> _pid1 and change the id variable from p_id1 to id. Do the same with copy
> 3+
> using different pre/postfixes and the next p_id variable. You can then
> merge each of these into the root copy using the p_idX as your merge
> variables and only keeping observations in the master.
>
> Hope this helps.
> Steve
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Juan Baron
> Sent: Wednesday, November 30, 2005 11:49 AM
> To: [email protected]
> Subject: st: Creation of family id
>
>
> Dear Stata Users:
>
> Suppose I have the following data
>
> id p_id1 p_id2 pid3
> 1 . . .
> 2 6 7 9
> 3 8 . .
> 4 5 1 .
> 5 . . .
> 6 . . .
> 7 . . .
> 8 . . .
> 9 . . .
> 10 5 . .
>
>
> where id is a unique id for each indiviidual and p_id#'s the id of the
> parent (in the real data I have more than 3 pid variables)
>
> I want to create a family id in the most efficient way. My solution to
> this problem involves looping over observations, and because of that
> it takes a long time. That wouldn't be a problem if my data contained
> only a few observations, but that is not the case.
>
> Can anybody suggest more efficient ways to do this task? I was
> wondering also, how about using MATA?
>
> Thanks,
>
> Juan
>
> *
> * 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/
>
>
> *
> * 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/
>
>
> *
> * 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/
>
*
* 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/