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: Can I use Many to Many merge for this case
From
Pablo Bonilla <[email protected]>
To
[email protected]
Subject
Re: st: Can I use Many to Many merge for this case
Date
Mon, 27 Aug 2012 10:57:15 -0400
One more thing: instead of tid and jid rename both variables as "id"
in each data base, so your identifier will be another variable. It is
like reshaping to long format.....
best,
On Mon, Aug 27, 2012 at 10:40 AM, Pablo Bonilla
<[email protected]> wrote:
> The first thing you have to think is how you need the data base and
> try to get in that way. Second, try to avoid many-to-many merges by
> using joinby. Finally my suggestion is using append instead of merge
> by modifying a little your original databases:
>
> training.dta:
>
> Id tid type sta end
> 1 1 1 01/05/2010 03/11/2010
> 1 2 1 05/20/2010 12/01/2010
> 2 1 1 03/05/2010 08/30/2010
> 2 2 1 07/30/2010 01/18/2011
> 3 1 1 02/09/2010 05/19/2010
>
> jobs.dta:
> Id jid type sta end wage
> 1 1 2 03/01/2010 04/30/2010 12
> 1 2 2 12/15/2010 03/15/2011 15
> 1 3 2 05/01/2010 03/11/2010 20
> 2 1 2 01/05/2010 03/31/2010 8
> 3 1 2 06/01/2010 07/11/2011 9
> 3 2 2 11/01/2010 12.5
>
>
> use training, clear
> append using jobs
>
> label define type 1 training 2 jobs
> label values type type
>
> I hope it works.
>
> Best,
>
>
>
> On Sun, Aug 26, 2012 at 1:23 PM, Nan Z <[email protected]> wrote:
>> Hey Stata
>> users,
>> I know that
>> STATA manual suggest avoiding many to many merge. I would like to know for the
>> following situation what I should do. Any suggestion is appreciated.
>> My research
>> question requires to determine the main activity of an individual in a month. For
>> example, if one person spends more than half a month in working, he will be in
>> the status of Job. Or he will be in the status of training if he takes more
>> time on training.
>> I have two
>> datasets-- training and job as following. As you can see that each individual
>> has more than one observation. This implies that they have at least one job or
>> participate in training at least once in the survey period. The tid/jid tells us
>> the training id or job id; t_sta/end is the start/ending time of training and
>> j_sta/end correspond to jobs.
>> My question
>> is whether I can use many to many merge. Or there is other better way to do
>> it. Thanks for any suggestions.
>> Best,
>> Nan
>>
>> Training:
>> Id tid t_sta t_end
>> 1 1 01/05/2010 03/11/2010
>> 1 2 05/20/2010 12/01/2010
>> 2 1 03/05/2010 08/30/2010
>> 2 2 07/30/2010 01/18/2011
>> 3 1 02/09/2010 05/19/2010
>>
>> Id jid j_sta j_end wage
>> 1 1 03/01/2010 04/30/2010 12
>> 1 2 12/15/2010 03/15/2011 15
>> 1 3 05/01/2010 03/11/2010 20
>> 2 1 01/05/2010 03/31/2010 8
>> 3 1 06/01/2010 07/11/2011 9
>> 3 2 11/01/2010 12.5
>>
>> *
>> * 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/
>
>
>
> --
> ----
>
> Pablo Bonilla
--
----
Pablo Bonilla
*
* 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/