Sas Beginner
Sas Beginner

Reputation: 275

BY statement in SAS proc compare

What is the difference in using the ID statement Vs the BY Statement in proc compare.

I understand the ID statement -- that when added observations are compared according to ID.. but what exactly BY statement does..

I did read the SAS documentation and searched net I couldt understand , can anybody elaborate on it .

Upvotes: 4

Views: 468

Answers (1)

Michael Hasan
Michael Hasan

Reputation: 1280

The way I understand it, the "by" statement makes proc compare do a separate comparison for each by group in the comparison data sets. It's basically like running a separate "proc compare" for each "by" group.

The "id" statement on the other hand correlates records by key between the two data sets to be compared and reports on the number of common elements and how many are in one data sets but not in the other. You would use this if your data sets have a common primary key i.e. a combination of variables that uniquely identify each record, and you want "prooc compare" to take each matching pair and compare them.

Upvotes: 6

Related Questions