Previous Page | Next Page

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

 Note about code
libname proclib 'SAS-library';
 Note about code
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: Listing

 Note about figure
                                               The Output Data Set RESULT                                              1

          idnum    _TYPE_     _OBS_    name               address                                       salary

          0987     BASE          1     Dolly Lunford      2344 Persimmons Branch  Apex NC 27505          44010
                   COMPARE       1     Dolly Lunford      2344 Persimmons Branch Trail Apex NC 27505     45110
                   DIF           1     ...............    .......................XXXXX.XXXXXXXXXXXXX      1100

          2776     BASE          5     Robert Jones       12988 Wellington Farms Ave. Cary NC 27512      29025
                   COMPARE       5     Robert Jones       12988 Wellington Farms Ave. Cary NC 27511      29025
                   DIF           5     ...............    ........................................X.         E

          3278     COMPARE       6     Mary Cravens       211 N. Cypress St. Cary NC 27512               35362

          3286     BASE          6     Hoa Nguyen         2818 Long St. Cary NC 27513                    87734
                   COMPARE       7     Hoa Nguyen         2818 Long St. Cary NC 27513                    89834
                   DIF           6     ...............    ..........................................      2100

          3888     BASE          7     Kim Siu            5662 Magnolia Blvd Southeast Cary NC 27513     77558
                   COMPARE       8     Kim Siu            5662 Magnolia Blvd Southwest Cary NC 27513     79958
                   DIF           7     ...............    ........................XX................      2400

          6544     COMPARE       9     Roger Monday       3004 Crepe Myrtle Court Raleigh NC 27604       47007

          9857     BASE         10     Kathy Krupski      1000 Taft Ave. Morrisville NC 27508            38756
                   COMPARE      12     Kathy Krupski      100 Taft Ave. Morrisville NC 27508             40456
                   DIF          10     ...............    ...XXXXXXXXXXXXXX.XXXXX.XXXXXXXXXXX.......      1700

Previous Page | Next Page | Top of Page