这个很简单!在stata中 运行 和help merge ,帮助中有有这样的例子!
In some datasets, multiple variables are required to identify the
observations. Imagine data obtained by observing patients at specific
points in time so that variables pid and time, taken together, identify
the observations. Below we have two such datasets and run a 1:1 merge on
pid and time,
. merge 1:1 pid time using filename
master + using = merged result
+-------------+ +-------------+ +-------------------------+
|pid time x1| |pid time x2| |pid time x1 x2 _merge|
|-------------| |-------------| |-------------------------|
| 14 1 0| | 14 1 7| | 14 1 0 7 3|
| 14 2 0| | 14 2 9| | 14 2 0 9 3|
| 14 4 0| | 16 1 2| | 14 4 0 . 1|
| 16 1 1| | 16 2 3| | 16 1 1 2 3|
| 16 2 1| | 17 1 5| | 16 2 1 3 3|
| 17 1 0| | 17 2 2| | 17 1 0 5 3|
+-------------+ +-------------+ | 17 2 . 2 2|
+-------------------------+
This is a 1:1 merge because the combination of the values of pid and time
uniquely identifies observations in both datasets.
By default, there is nothing about a 1:1 merge that implies that all, or
even any of, the observations match. Above five observations matched,
one observation was only in the master (subject 14 at time 4), and
another was only in the using (subject 17 at time 2).
|