I have two datasets that I want to merge into one dataset.
The master dataset consists of individual survey data where each interviewed individual has one row (including a country variable).
Dataset two consists of event data which is structured as follows: for each unique event date there is one row (including the country the event takes place), one country can have multiple events taking place, hence, for one country there are multiple rows.
Now, I want to merge dataset one with dataset two using the country as the unique identifier such that I get for each individual one row:
ID x1 x2 x3 country event1 y11 y21 y31 event 2 y12 y22 y32
One way to achieve this is to use:
and then to
.
Is there an easier way to do it, e.g. with a merge command?
The master dataset consists of individual survey data where each interviewed individual has one row (including a country variable).
Dataset two consists of event data which is structured as follows: for each unique event date there is one row (including the country the event takes place), one country can have multiple events taking place, hence, for one country there are multiple rows.
Now, I want to merge dataset one with dataset two using the country as the unique identifier such that I get for each individual one row:
ID x1 x2 x3 country event1 y11 y21 y31 event 2 y12 y22 y32
One way to achieve this is to use:
Code:
joinby country using ...
Code:
reshape ..., i(id) j(event)
Is there an easier way to do it, e.g. with a merge command?

Comment