I have the following data that I want to merge:
Master dataset:
statalist_data4.dta
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 gvkey int(datadate rdq) "001010" 5568 5589 "001010" 5659 5680 "001010" 5751 5771 "001010" 5843 5886 "001010" 5934 5956 "001010" 6025 6046 "001010" 6117 6137 "001010" 6209 6248 "001010" 6299 6326 "001010" 6390 6411 "001010" 6482 6506 "001010" 6574 6614 "001010" 6664 6685 "001010" 6755 6781 "001010" 6847 6874 "001010" 6939 6979 "001010" 7029 7049 "001010" 7120 7144 "001010" 7212 7237 "001010" 7304 7350 "001010" 7395 7419 "001010" 7486 7515 "001010" 7578 7602 "001010" 7670 7713 "001010" 7760 7787 "001010" 7851 7872 "001010" 7943 7965 "001010" 8035 8083 "001010" 8125 8146 "001010" 8216 8238 "001010" 8308 8329 "001010" 8400 8445 "001010" 8490 8516 "001010" 8581 8608 "001010" 8673 8699 "001010" 8765 8805 "001010" 8856 8903 "001010" 8947 . "001010" 9039 . "001010" 9131 . "001010" 9221 . "001010" 9312 . "001010" 9404 . "001010" 9496 . "001010" 9586 . "001010" 9677 . "001010" 9769 . "001010" 9861 . "001010" 9951 . "001010" 10042 . "001010" 10134 . "001010" 10226 . "001010" 10317 . "001010" 10408 . "001010" 10500 . "001010" 10592 . "001010" 10682 . "001010" 10773 . "001010" 10865 . "001010" 10957 . "001010" 11047 . "001010" 11138 . "001010" 11230 . "001010" 11322 . "001010" 11412 . "001010" 11503 . "001010" 11595 . "001010" 11687 . "001010" 11778 . "001010" 11869 . "001010" 11961 . "001010" 12053 . "001010" 12143 . "001010" 12234 . "001010" 12326 . "001010" 12418 . "001010" 12508 . "001010" 12599 . "001010" 12691 . "001010" 12783 . "001010" 12873 . "001010" 12964 . "001010" 13056 . "001010" 13148 . "001010" 13239 . "001010" 13330 . "001010" 13422 . "001010" 13514 . "001010" 13604 . "001010" 13695 . "001010" 13787 . "001010" 13879 . "001010" 13969 . "001010" 14060 . "001010" 14152 . "001010" 14244 . "001010" 14334 . "001010" 14425 14490 "001010" 14517 . "001010" 14609 14731 end format %td datadate
and using dataset:
statalist_lnk.dta
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 gvkey long permno int(linkdt linkenddt) "001010" 10006 -3532 760 "001010" 10006 761 8945 end format %td linkdt format %td linkenddt
Code:
use statalist_data4.dta, clear merge m:m gvkey using statalist_lnk.dta
I am getting the same number of observations as the master dataset (118) whereas I would like the number of observations to double (double because 2 obs in the using dataset, hence 2*118) to reflect the fact that the 2 "gvkey" in the using dataset could be match twice to each of the "gvkey" in the master dataset (then I would have all possible combinations). I think "merge" may not be the right way to do it here. Can someone help me get what I want? Thanks a lot in advance.
0 Response to many-to-many merge problem
Post a Comment