Below I have a sample of two datasets: set1 and set2. I need to merge them. The problem is that there are repetitive firms (gvkey) and date (trading_date) observation. So, I merge using many-to-many option. However, I came across this:
"Because m:m merges are such a bad idea, we are not going to show you an example. If you think that you need an m:m merge, then you probably need to work with your data so that you can use a 1:m or m:1 merge." (append-merge-collapse.pdf (arizona.edu)).
And I am curious if it is ok to merge m:m?
Set1
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double gvkey float trading_date 10031 10350 10031 10349 10031 10346 10031 10345 10031 10344 10031 10343 10031 10342 10031 10339 10031 10338 10031 10337 10031 10336 10031 10335 10031 10332 10031 10331 10031 10330 10031 10329 10031 10328 10031 10325 10031 10324 10031 10323 10031 10322 10031 10321 10031 10317 10031 10316 10032 10350 10032 10349 10032 10346 10032 10345 10032 10344 10032 10343 10032 10342 10032 10339 10032 10338 10032 10337 10032 10336 10032 10335 10032 10332 10032 10331 10032 10330 10032 10329 10032 10328 10032 10325 10032 10324 10032 10323 10032 10322 10032 10321 10032 10317 10032 10316 end format %td trading_date
Set2
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double personid str2 status double gvkey float trading_date 12000001 "S" 10031 10324 12000001 "P" 10031 10330 12500004 "S" 10031 10330 12500004 "S" 10032 10324 12500005 "S" 10032 10324 12500005 "P" 10032 10324 12500005 "S" 10032 10330 12500010 "P" 10032 10330 12500010 "S" 10032 10330 end
0 Response to Merging two datasets - m:m
Post a Comment