Chapter Contents

Previous

Next
The COMPARE Procedure

Example 6: Comparing Values of Observations Using an Output Data Set (OUT=)


Procedure features:
PROC COMPARE statement options:
NOPRINT
OUT=
OUTBASE
OUTBASE
OUTCOMP
OUTDIF
OUTNOEQUAL
Other features: PRINT procedure
Data sets: PROCLIB.EMP95 and PROCLIB.EMP96

This example creates and prints an output data set that shows the differences between matching observations.

In Comparing Observations with an ID Variable , the output does not show the differences past the 20th character. The output data set in this example shows the full values. Further, it shows the observations that occur in only one of the data sets.


Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=120 pagesize=40;



 Note about code
proc sort data=proclib.emp95 out=emp95_byidnum;

 by idnum;
run;

proc sort data=proclib.emp96 out=emp96_byidnum;
   by idnum;
run;
 Note about code
proc compare base=emp95_byidnum compare=emp96_byidnum
 Note about code
             out=result outnoequal outbase outcomp outdif
     noprint;


 Note about code
   id idnum;
run;
 Note about code
proc print data=result noobs;
   by idnum;
   id idnum;
   title 'The Output Data Set RESULT';
run;


Output
The differences for character variables are noted with an X or a period (.). An X shows that the characters do not match. A period shows that the characters do match. For numeric variables, an E means that there is no difference. Otherwise, the numeric difference is shown. By default, the output data set shows that two observations in the comparison data set have no matching observation in the base data set. You do not have to use an option to make those observations appear in the output data set. [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.