Chapter Contents |
Previous |
Next |
The COMPARE Procedure |
PROC COMPARE compares two data sets: the base data set and the comparison data set. The procedure determines matching variables and matching observations. Matching variables are variables with the same name or variables that you explicitly pair by using the VAR and WITH statements. Matching variables must be of the same type. Matching observations are observations that have the same values for all ID variables that you specify or, if you do not use the ID statement, that occur in the same position in the data sets. If you match observations by ID variables, both data sets must be sorted by all ID variables.
When you compare data sets using PROC COMPARE, you receive the following type of information:
Further, PROC COMPARE creates two kinds of output data sets that give detailed information about the differences between observations of variables it is comparing.
The following example compares the data sets PROCLIB.ONE and PROCLIB.TWO, which contain similar data about students:
data proclib.one(label='First Data Set'); input student year $ state $ gr1 gr2; label year='Year of Birth'; format gr1 4.1; datalines; 1000 1970 NC 85 87 1042 1971 MD 92 92 1095 1969 PA 78 72 1187 1970 MA 87 94 ; data proclib.two(label='Second Data Set'); input student $ year $ state $ gr1 gr2 major $; label state='Home State'; format gr1 5.2; datalines; 1000 1970 NC 84 87 Math 1042 1971 MA 92 92 History 1095 1969 PA 79 73 Physics 1187 1970 MD 87 74 Dance 1204 1971 NC 82 96 French ;
PROC COMPARE produces lengthy output. You can use one or more options to determine the kinds of comparisons to make and the degree of detail in the report. For example, in the following PROC COMPARE step, the NOVALUES option suppresses the part of the output that shows the differences in the values of matching variables:
proc compare base=proclib.one compare=proclib.two novalues; run;
Procedure Output shows the default output for these two data sets. Producing a Complete Report of the Differences shows the complete output for these two data sets.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.