|
One way to do this if you don't have too many duplicates, is to put each of duplicate observations into a different data set, then compare the two datasets to each other.
For instance, below I've got up to two observations per my ID. I take only those that have duplicates, then put them into two different data sets, then do a compare on the two different data sets. Note I'm assuming that "visitid" is unique across all patients (if yours is not, create a new ID by concatenating the patient ID and the visit ID together).
proc sql;
create table duplicates as
select *
from data_check
where visitid in(
select visitid
from data_master
group by visitid
having count(visitid) =2)
order by visitid;
quit;
run;
data duplicates1 duplicates2;
set duplicates;
by visitid;
if first.visitid then output duplicates1;
if last.visitid then output duplicates2;
run;
ods trace on;
ods select CompareDifferences;
ods output CompareDifferences=CompareDifferences_set;
proc compare base=duplicates1
compare=duplicates2 NOMISSBASE NOMISSCOMP;
by visitid;
run;
Things would get a lot trickier if you could have more than two of a particular visitid, but perhaps you could pull two at a time and resolve those first.
-Mary
----- Original Message -----
From: idostatistics@GMAIL.COM
To: SAS-L@LISTSERV.UGA.EDU
Sent: Friday, May 30, 2008 1:33 PM
Subject: Using PROC COMPARE , comparing by sub group ( patient visit )
How do you use PROC COMPARE for , not row-by-row comparison, but
compare by individuals, say by PATIENT or PATIENT-VISIT, to produce an
output dataset that has the rows for all patients or patient-visits
for which the data is in any way different?
|