PROC COMPARE stores a return code
in the automatic macro variable SYSINFO. The value of the return
code provides information about the result of the comparison. By checking
the value of SYSINFO after PROC COMPARE has run and before any other
step begins, SAS macros can use the results of a PROC COMPARE step
to determine what action to take or what parts of a SAS program to
execute.
The following table
is a key for interpreting the SYSINFO return code from PROC COMPARE.
For each of the conditions listed, the associated value is added to
the return code if the condition is true. Thus, the SYSINFO return
code is the sum of the codes listed in the following table for the
applicable conditions:
Macro Return Codes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Variable has different
informat
|
|
|
|
|
Variable has different
format
|
|
|
|
|
Variable has different
length
|
|
|
|
|
Variable has different
label
|
|
|
|
|
Base data set has observation
not in comparison
|
|
|
|
|
Comparison data set
has observation not in base
|
|
|
|
|
Base data set has BY
group not in comparison
|
|
|
|
|
Comparison data set
has BY group not in base
|
|
|
|
|
Base data set has variable
not in comparison
|
|
|
|
|
Comparison data set
has variable not in base
|
|
|
|
|
A value comparison was
unequal
|
|
|
|
|
Conflicting variable
types
|
|
|
|
|
BY variables do not
match
|
|
|
|
|
Fatal error: comparison
not done
|
These codes are ordered
and scaled to enable a simple check of the degree to which the data
sets differ. For example, if you want to check that two data sets
contain the same variables, observations, and values, but you do not
care about differences in labels, formats, and so on, then use the
following statements:
proc compare base=SAS-data-set
compare=SAS-data-set;
run;
%if &sysinfo >= 64 %then
%do;
handle error;
%end;
You can examine individual
bits in the SYSINFO value by using DATA step bit-testing features
to check for specific conditions. For example, to check for the presence
of observations in the base data set that are not in the comparison
data set, use the following statements:
proc compare base=SAS-data-set
compare=SAS-data-set;
run;
%let rc=&sysinfo;
data _null_;
if &rc='1......'b then
put 'Observations in Base but not
in Comparison Data Set';
run;
PROC COMPARE must run
before you check SYSINFO and you must obtain the SYSINFO value before
another SAS step starts because every SAS step resets SYSINFO.