id unique ;
run;
Proc Print data=toprint;
run;
Variables with Unequal Values
Variable Type Len Label Ndif MaxDif
WEIGHTKG NUM 8 Weight in kg 4 0.700
Value Comparison Results for Variables
_______________________________________________________
||Weight in kg
|| Base Compare
Unique || WEIGHTKG WEIGHTKG Diff. % Diff
_________ || ________ ________ ________ _________
||
20110 || 85.7 85.0 -0.7000 -0.8168
20120 || 101.6 101.0 -0.6000 -0.5906
20130 || 94.3 94.0 -0.3000 -0.3181
20202 || 99.3 99.0 -0.3000 -0.3021
______________________________________________________
OUTPUT OF PROC PRINT
Obs _TYPE_ _OBS_ Unique WEIGHTKG dob
1 DIF 1 20110 -0.7 E
2 DIF 2 20120 -0.6 E
3 DIF 3 20130 -0.3 E
4 DIF 4 20202 -0.3 E
It is possible to use the noprint option, but then it is strongly
recommended to use the options OUTCOMP AND OUTBASE to
differentiate the variables.
proc compare data=demog
compare=compare
outnoequal
out=toprint
noprint
outcomp
outbase;
id unique ;
run;
proc print data=toprint;
run;
Obs _TYPE_ _OBS_ Unique WEIGHTKG dob
1 BASE 1 20110 85.7 09/17/1949
2 COMPARE 1 20110 85.0 09/17/1949
3 BASE 2 20120 101.6 08/19/1949
4 COMPARE 2 20120 101.0 08/19/1949
5 BASE 3 20130 94.3 06/02/1934
6 COMPARE 3 20130 94.0 06/02/1934
7 BASE 4 20202 99.3 10/17/1931
8 COMPARE 4 20202 99.0 10/17/1931
A USEFUL DATASET TO REPORT
To get only the observations and variables that have
discrepancies, proc transpose can be a big help in reporting the
findings.
proc transpose data=toprint out=transp;
by unique _obs_;
id _type_;
run;
proc print data=transp(where=(base^=compare));
run;
Obs Unique _OBS_ _NAME_ _LABEL_ BASE COMPARE
1 20110 1 WEIGHTKG Weight in kg 85.7 85
3 20120 2 WEIGHTKG Weight in kg 101.6 101
5 20130 3 WEIGHTKG Weight in kg 94.3 94
7 20202 4 WEIGHTKG Weight in kg 99.3 99
CONCLUSION
You are the person who decides what is important to validate,
values of the observations and how different can they be. Is it
important to have the same labels, formats and informats in a
variable. Proc Compare is a tool that is flexible to allow you find
the differences that are important to you.
ACKNOWLEDGMENTS
I want to thank, Craig Mauldin, Andy Barnett, George Clark,
Bonnie Duncan and Kim Sturgen for their comments and support.
CONTACT INFORMATION
Your comments and questions are valued and encouraged.
Contact the author at:
A. Cecilia Casas
PPD Development
3900 Paramount Parkway
Morrisville, NC 27560
Phone: (919) 462-4199
Fax: (919) 379-6151
Email:
[email protected]
SAS and all other SAS Institute Inc. product or service names are
registered trademarks or trademarks of SAS Institute Inc. in the
USA and other countries. ® indicates USA registration.
Other brand and product names are trademarks of their
respective companies.