Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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 <pablo.bonilla1234@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Can I use Many to Many merge for this case
Date   Mon, 27 Aug 2012 10:40:55 -0400

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 <nanz_mont@yahoo.ca> 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
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index