Previous Page | Next Page

The COMPARE Procedure

Example 1: Producing a Complete Report of the Differences


Procedure features:

PROC COMPARE statement options

BASE=

PRINTALL

COMPARE=

Data sets:

PROCLIB.ONE, PROCLIB.TWO


This example shows the most complete report that PROC COMPARE produces as procedure output.


Program

 Note about code
libname proclib 'SAS-library';
 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
proc compare base=proclib.one compare=proclib.two printall;
   title 'Comparing Two Data Sets: Full Report';
run;

Output: Listing

 Note about figure
                      Comparing Two Data Sets: Full Report                     1

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

                               Data Set Summary 

 Dataset               Created          Modified  NVar    NObs  Label          

 PROCLIB.ONE  11SEP97:16:19:59  11SEP97:16:20:01     5       4  First Data Set 
 PROCLIB.TWO  11SEP97:16:20:01  11SEP97:16:20:01     6       5  Second Data Set


                               Variables Summary

               Number of Variables in Common: 5.
               Number of Variables in PROCLIB.TWO but not in PROCLIB.ONE: 1.
               Number of Variables with Conflicting Types: 1.
               Number of Variables with Differing Attributes: 3.


           Listing of Variables in PROCLIB.TWO but not in PROCLIB.ONE

                             Variable  Type  Length

 >                            major     Char       8


               Listing of Common Variables with Conflicting Types

                      Variable  Dataset      Type  Length

                      student   PROCLIB.ONE  Num        8
                                PROCLIB.TWO  Char       8
                      Comparing Two Data Sets: Full Report                     2

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

             Listing of Common Variables with Differing Attributes

           Variable  Dataset      Type  Length  Format  Label        

           year      PROCLIB.ONE  Char       8          Year of Birth
                     PROCLIB.TWO  Char       8                       
           state     PROCLIB.ONE  Char       8                       
                     PROCLIB.TWO  Char       8          Home State   
           gr1       PROCLIB.ONE  Num        8  4.1                  
                     PROCLIB.TWO  Num        8  5.2                  


                      Comparison Results for Observations

>        Observation 5 in PROCLIB.TWO not found in PROCLIB.ONE.


                              Observation Summary

                         Observation      Base  Compare

                         First Obs           1        1
                         First Unequal       1        1
                         Last  Unequal       4        4
                         Last  Match         4        4
                         Last  Obs           .        5

        Number of Observations in Common: 4.
        Number of Observations in PROCLIB.TWO but not in PROCLIB.ONE: 1.
        Total Number of Observations Read from PROCLIB.ONE: 4.
        Total Number of Observations Read from PROCLIB.TWO: 5.

        Number of Observations with Some Compared Variables Unequal: 4.
        Number of Observations with All Compared Variables Equal: 0.
                      Comparing Two Data Sets: Full Report                     3

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

                           Values Comparison Summary

        Number of Variables Compared with All Observations Equal: 1.
        Number of Variables Compared with Some Observations Unequal: 3.
        Total Number of Values which Compare Unequal: 6.
        Maximum Difference: 20.


                        Variables with All Equal Values

>                     Variable  Type  Len   Label

                     year      CHAR    8   Year of Birth

                         Variables with Unequal Values

              Variable  Type  Len   Compare Label  Ndif   MaxDif

              state     CHAR    8   Home State        2
              gr1       NUM     8                     2    1.000
              gr2       NUM     8                     2   20.000
                      Comparing Two Data Sets: Full Report                     4

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

                     Value Comparison Results for Variables

           __________________________________________________________
                      ||  Year of Birth
                      ||  Base Value           Compare Value
                  Obs ||  year                  year
            ________  ||  ________              ________
                      ||
                   1  ||  1970                  1970
                   2  ||  1971                  1971
                   3  ||  1969                  1969
                   4  ||  1970                  1970
           __________________________________________________________


           __________________________________________________________
                      ||  Home State
                      ||  Base Value           Compare Value
                  Obs ||  state                 state
            ________  ||  ________              ________
                      ||
                   1  ||  NC                    NC
                   2  ||  MD                    MA
                   3  ||  PA                    PA
                   4  ||  MA                    MD
           __________________________________________________________
                      Comparing Two Data Sets: Full Report                     5

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

                     Value Comparison Results for Variables

           __________________________________________________________
                      ||       Base    Compare
                  Obs ||        gr1        gr1      Diff.     % Diff
            ________  ||  _________  _________  _________  _________
                      ||
                   1  ||       85.0      84.00    -1.0000    -1.1765
                   2  ||       92.0      92.00          0          0
                   3  ||       78.0      79.00     1.0000     1.2821
                   4  ||       87.0      87.00          0          0
            ________  ||  _________  _________  _________  _________
  >                   ||
               N      ||          4          4          4          4
              Mean    ||    85.5000    85.5000          0     0.0264
              Std     ||     5.8023     5.4467     0.8165     1.0042
              Max     ||    92.0000    92.0000     1.0000     1.2821
              Min     ||    78.0000    79.0000    -1.0000    -1.1765
             StdErr   ||     2.9011     2.7234     0.4082     0.5021
               t      ||    29.4711    31.3951     0.0000     0.0526
            Prob>|t|  ||     <.0001     <.0001     1.0000     0.9614
                      ||
             Ndif     ||          2     50.000%
            DifMeans  ||      0.000%     0.000%         0
             r, rsq   ||      0.991      0.983
           __________________________________________________________
                      Comparing Two Data Sets: Full Report                     6

                               COMPARE Procedure
                   Comparison of PROCLIB.ONE with PROCLIB.TWO
                                 (Method=EXACT)

                     Value Comparison Results for Variables

           __________________________________________________________
                      ||       Base    Compare
                  Obs ||        gr2        gr2      Diff.     % Diff
            ________  ||  _________  _________  _________  _________
                      ||
                   1  ||    87.0000    87.0000          0          0
                   2  ||    92.0000    92.0000          0          0
                   3  ||    72.0000    73.0000     1.0000     1.3889
                   4  ||    94.0000    74.0000   -20.0000   -21.2766
            ________  ||  _________  _________  _________  _________
  >                   ||
               N      ||          4          4          4          4
              Mean    ||    86.2500    81.5000    -4.7500    -4.9719
              Std     ||     9.9457     9.4692    10.1776    10.8895
              Max     ||    94.0000    92.0000     1.0000     1.3889
              Min     ||    72.0000    73.0000   -20.0000   -21.2766
             StdErr   ||     4.9728     4.7346     5.0888     5.4447
               t      ||    17.3442    17.2136    -0.9334    -0.9132
            Prob>|t|  ||     0.0004     0.0004     0.4195     0.4285
                      ||
             Ndif     ||          2     50.000%
            DifMeans  ||     -5.507%    -5.828%   -4.7500
             r, rsq   ||      0.451      0.204
           __________________________________________________________

Previous Page | Next Page | Top of Page