SAS Proc Compare

SAS Day 15: Proc Compare

 

Problem: Suppose we need to compare the dataset Prod and QC.

 

Background:

We use Proc Compare to compare the value of two datasets. The report will give us the summary of two dataset.  Proc compare has many options, the ones I like the most are: Criterion, Var…. With, Listall, Id, Out.

Criterion: Set the compare decimal places.
E.g. criterion=0.001.

Var…With: Compare the attributes with different names.
E.g.  Var aval; With aval1;

Listall: List all the comparison results.

Id: Specify the compared order.
E.g: Id usubjid visitnum visdtc;

Out: Output a dataset for compared results.

Basic Syntax:

Proc Compare Base=a Compare=b listall criterion=0.0001;
var x y z;
with a b c;
run;

 

Solution:

Output:

Obviously, Prod and QC dataset did not match. So we need to go back and digging what caused the discrepancies and fix it!

 

Happy SAS Coding! ☺

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: