|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: question about merge / lookup (was Re: statlist: offlist follow up)
From |
"Michael Blasnik" <[email protected]> |
To |
<[email protected]> |
Subject |
Re: question about merge / lookup (was Re: statlist: offlist follow up) |
Date |
Tue, 17 Jul 2007 09:58:03 -0400 |
...
I don't understand how this merge is supposed to work -- it looks like a
"many-to-many" merge because there is no unique set of key variables in either
dataset. I thought the proyeccion was supposed to be some population info, but
then why does it have two entries for the values 0 2 2 for agegp dpto e1?
You need to come up with a way for Stata to determine which observations go
together or you will end up with multiple matches.
Michael Blasnik
----- Original Message -----
From: "Sebastian Kruk" <[email protected]>
To: <[email protected]>
Sent: Tuesday, July 17, 2007 1:30 AM
Subject: Re: question about merge / lookup (was Re: statlist: offlist follow up)
Sorry Michael, I thought it was sent it by statalist. I have problems
some weeks ago because I sent a message off-list.
I have two datasets (a.dta and b.dta) as follows:
a.dta
agegp dpto e1 proyeccion
0 1 1 9261
1 1 1 36894
5 1 1 47986
0 1 1 48976
1 1 2 8863
5 1 2 35504
0 2 2 46194
1 2 1 47042
5 2 1 10401
0 2 2 4555
1 2 2 1543
5 2 2 519
b.dta:
agegp dpto e1 vaca0 vaca1
0 1 1 9261 6174
1 1 1 36894 24596
5 1 1 47986 31990
0 1 1 48976 32650
1 1 2 8863 5908
5 1 2 35504 23669
0 2 2 2133 455
1 2 1 2212 48971
5 2 1 108 1170
0 2 2 20 4304
1 2 2 238 566
5 2 2 2 72
0 1 1 9261 61
1 1 1 36894 245
5 1 1 47986 31
0 1 1 48976 3
1 1 2 8863 590
5 1 2 35504 236
0 2 2 213 455
1 2 1 221 48
5 2 1 108 11
0 2 2 2074 43
1 2 2 238 5
5 2 2 269 72
I am trying to merge the two datasets such that the new dataset should read
as:
agegp dpto e1 vaca0 vaca1 proyeccion
0 1 1 9261 6174 9261
1 1 1 36894 24596 36894
5 1 1 47986 31990 47986
0 1 1 48976 32650 48976
1 1 2 8863 5908 8863
5 1 2 35504 23669 35504
0 2 2 2133 455 46194
<snip>
*
* 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/