Previous PageNext Page

Missing Observations
What if you want to "fix" the above example by retaining only those observations that matched?

TITLE 'Like Example 5 in C&P Chapter 3';
Proc Sort data=GenYear;
     BY Subj;
     WHERE Subj NE 5;
Proc Sort data=HtWt;
     BY Subj;
     WHERE Subj NE 8;
Data Survey12;
     Merge GenYear (IN=InGenYr)
           HtWt    (IN=InHtWt);
     BY Subj;
     IF InGenYr = 1 AND InHtWt = 1;
Proc Print;
     ID Subj;

The IN= option of a SAS data set name specifies that you want to add a variable to the program data vector. The variable names (here InGenYr and InHtWt you make up). The IN variable for GENYR will be true when the observation in the program data vector includes any information that came from GENYR. The IN variable for HtWt will be true when the observation in the program data vector includes any information that came from HtWt.

Like Example 5 in C&P Chapter 3

SUBJ    GENDER    HEIGHT    WEIGHT

  1       M         68        155
  7       F         72        205
  9       M         66        120

Only those observations that were in both GenYear and HtWt are output. IN variables are automatically dropped. They are not included in the output data file.

Previous PageTable Of ContentsNext Page