The data looks like:
ID----X1----X2----X3----Z1----Z2----Z3
For each ID, consider two sets of variables {X1, X2, X3}
and {Z1, Z2, Z3}
that:
- The numbers of Xs and Zs may be equal or not. They may also have missing values.
- Values of variables in each set is unique. That is, for each ID, X1 not equal X2 not equal X3. The same applies for Zs.
- Values of Xs and Zs can be equal, and there comes the question. How can I create a new data that retains equal values of Xs and Zs and exclude unequal values. For example, if X1 is equal to any Zs, then X1 will be retained together with the Z.
Consider a hypothetical data:
data temp;
input ID x1 x2 x3 z1 z2 z3;
datalines;
1001 11 12 13 . 12 11
1002 21 22 23 24 25 26
1003 31 32 33 31 32 .
1004 41 42 43 41 44 45
;
run;
I want it to be:
1001 11 12 . . 12 11
1002 . . . . . .
1003 31 32 . 31 32 .
1004 41 . . 41 . .