COMPARE Procedure

Example 7: Creating an Output Data Set of Statistics (OUTSTATS=)

Features:
PROC COMPARE statement options:
NOPRINT
OUTSTATS=
Data sets: PROCLIB.EMP95

PROCLIB.EMP96

Details

This example creates an output data set that contains summary statistics for the numeric variables that are compared.

Program

libname proclib 'SAS-library';
options nodate pageno=1 linesize=80 pagesize=40;
proc sort data=proclib.emp95 out=emp95_byidnum;
   by idnum;
run;

proc sort data=proclib.emp96 out=emp96_byidnum;
   by idnum;
run;
proc compare base=emp95_byidnum compare=emp96_byidnum
             outstats=diffstat noprint;
   id idnum;
run;
proc print data=diffstat noobs;
   title 'The DIFFSTAT Data Set';
run;

Program Description

Declare the PROCLIB SAS library.
libname proclib 'SAS-library';
Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. PAGENO= specifies the starting page number. LINESIZE= specifies the output line length, and PAGESIZE= specifies the number of lines on an output page.
options nodate pageno=1 linesize=80 pagesize=40;
Sort the data sets by the ID variable. Both data sets must be sorted by the variable that will be used as the ID variable in the PROC COMPARE step. OUT= specifies the location of the sorted data.
proc sort data=proclib.emp95 out=emp95_byidnum;
   by idnum;
run;

proc sort data=proclib.emp96 out=emp96_byidnum;
   by idnum;
run;
Create the output data set of statistics and compare observations that have matching values for the ID variable. BASE= and COMPARE= specify the data sets to compare. OUTSTATS= creates the output data set DIFFSTAT. NOPRINT suppresses the procedure output. The ID statement specifies IDNUM as the ID variable. PROC COMPARE uses the values of IDNUM to match observations.
proc compare base=emp95_byidnum compare=emp96_byidnum
             outstats=diffstat noprint;
   id idnum;
run;
Print the output data set DIFFSTAT. PROC PRINT prints the output data set DIFFSTAT.
proc print data=diffstat noobs;
   title 'The DIFFSTAT Data Set';
run;
The variables are described in Output Statistics Data Set (OUTSTATS=).
The DIFFSTAT Data Set