| Merging SAS Data Sets |
| Excluding Unmatched
Observations |
| Creating Temporary IN= Variables
For example, suppose you want to match-merge the data sets Clinic.Demog and Clinic.Visit and select only observations that appear in both data sets. First, you use IN= to create two temporary variables, |
General form, IN= data set option:
where
Within the DATA step, the value of the variable is 1 if the data set contributed data to the current observation, and 0 otherwise. |
The DATA step containing the IN= options appears below.
The first IN= creates the temporary variable InDemog, which
is set to 1 when an observation from Clinic.Demog
contributes to the current observation; otherwise, it is set to
0. Likewise, the value of InVisit depends on whether
Clinic.Visit contributes to an observation or not. |
data clinic.combined;
merge clinic.demog(in=indemog)
clinic.visit(in=invisit
rename=(date=BirthDate));
by id;
run;
|
| When you specify multiple data set options for a given data set, enclose them in a single set of parentheses. |
![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.