COMPARE Procedure

Example 4: Comparing Variables That Are in the Same Data Set

Features:
PROC COMPARE statement options:
ALLSTATS
BRIEFSUMMARY

VAR statement

WITH statement

Data set: PROCLIB.ONE

Details

This example shows that PROC COMPARE can compare two variables that are in the same data set.

Program

libname proclib 'SAS-library';
options nodate pageno=1 linesize=80 pagesize=40;
proc compare base=proclib.one allstats briefsummary;
   var gr1;
   with gr2;
   title 'Comparison of Variables in the Same 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;
Create a short summary report of the differences within one data set. ALLSTATS prints summary statistics. BRIEFSUMMARY prints only a short comparison summary.
proc compare base=proclib.one allstats briefsummary;
Specify two variables from the base data set to compare. The VAR and WITH statements specify the variables in the base data set to compare. This example compares GR1 with GR2. Because there is no comparison data set, the variables GR1 and GR2 must be in the base data set.
   var gr1;
   with gr2;
   title 'Comparison of Variables in the Same Data Set';
run;

Output: HTML

Comparison of One Variable with Two Variables