Good morning everyone, for a research that I'm performing I'm trying to merge dataset A and dataset B, my goal is to get the third table. Here is my design:
Firstly I want to use ID1 to merge, and some of them couldn;t be merged(like 3) .
Then I want to use ID2 to merge the unmerged ones.
Please could you be kindly to tell me how to realize this in stata?
Dataset-A:
Dataset-B:
Expected Dataset:
Thanks !!
Firstly I want to use ID1 to merge, and some of them couldn;t be merged(like 3) .
Then I want to use ID2 to merge the unmerged ones.
Please could you be kindly to tell me how to realize this in stata?
Dataset-A:
| id1 | id2 | sells |
| 1 | 11 | 4 |
| 1 | 11 | 5 |
| 1 | 11 | 6 |
| 2 | 22 | 3 |
| 2 | 22 | 3 |
| 3 | 33 | 4 |
| 3 | 33 | 2 |
Dataset-B:
| id1 | id2 | costs |
| 1 | 11 | 0.2 |
| 2 | . | 0.3 |
| . | 33 | 0.4 |
Expected Dataset:
| id1 | id2 | sells | costs |
| 1 | 11 | 4 | 0.2 |
| 1 | 11 | 5 | 0.2 |
| 1 | 11 | 6 | 0.2 |
| 2 | 22 | 3 | 0.3 |
| 2 | 22 | 3 | 0.3 |
| 3 | 33 | 4 | 0.4 |
| 3 | 33 | 2 | 0.4 |

Comment