Compare

 

Overview
Comparison macro to evaluate the differences between SAS dataset.  

%compare (olddata = old data,
                   newdata = new data, 
                   method = comparison method,
                   output = output report,
                   basecode = SAS base code);
  
Where Is Type... And represents...
olddata C (80 chars) Original SAS dataset(s) used in comparison.  For one dataset, a two level name specification is used such as:

libname.dataset

An entire library can be specified by just having a one level name specified.  In this case, all SAS dataset from the specified library will be specified to be compared.  For this to work, the same set of dataset names must exist in the library specified for the NEWDATA.
newdata C (80 chars) New SAS dataset(s) used to  compare against old data.  For one dataset, a two level name specification is used such as:

libname.dataset

An entire library can be specified by just having a one level name specified.  In this case, all SAS dataset from the specified library will be specified to be compared.  For this to work, the same set of dataset names must exist in the library specified for the OLDDATA.
method C (20 chars) The method of judging equality of numeric values.  Valid values include:
  • exact (default)
  • absolute
  • percent
  • relative
output C (200 chars) The specified output HTML report file.  This can include the entire path and file name.  If only the file is specified, it will save the report at the current path.  If nothing is specified, then the default report file of COMPARE.HTML will be generated.
basecode C (200 chars Optional) This optional feature will produce a SAS program BASE code which performs the equivalent comparison.  If nothing is specified, no program is produced. If only the program name is specified, it must end with the extension of (.sas) and will be produced in the current directory.  You can also specify the entire path along with the file name.

Description
This tool can be used to compare two datasets or two sets of data as specified through library names.  An HTML report will be produced detailing the differences between values from the two datasets.  This is useful during validation between sets of data that are suppose to be the same such as in the case of data migration.

Example
%compare (olddata = inlib.ae,
                   newdata = outlib.ae);

%compare (olddata = inlib,
                   newdata = outlib);

%compare (olddata = inlib,
                   newdata = outlib,
                   output = c:\mypath\compare_report.html);

%compare (olddata = inlib,
                   newdata = outlib,
                   output = c:\mypath\compare_report.html,
                   basecode = c:\mypath\compare.sas);

 
 last updated on November 30.2007