Previous PageNext Page

One-to-one merges
Create a single data set from the information in the two data sets.

Title 'Like Example 3 in C&P Chapter 3';
Data Survey12;
     Merge GenYear HtWt;
Proc Print;
     ID Subj;

The new data set has all the variables that are in any of the data sets.
The new data set has all the observations in each of the data.

Like Example 3 in C&P Chapter 3

SUBJ    GENDER    YEAR    HEIGHT    WEIGHT

  1       M        91        68       155
  7       F        90        72       205
  9       M        93        66       120
  5       F        92       102        63
  8       M        91       250        70

Actually, you were lucky here. The data sets were built so that they would match up in a one-to-one manner. The subjects were in the same order. Each observation in one data set "went with" its pair in the other data set.
Usually you aren't so lucky. C&P say "This type of merge (one-to-one) can get you in big trouble and is rarely used (notice they do not say "never" ..." (page 69).

Rule: Never use a one-to-one merge. (Well, almost never.)

Previous PageTable Of ContentsNext Page