Date: Fri, 30 May 2008 13:54:27 -0500
Reply-To: Mary <email@example.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary <mlhoward@AVALON.NET>
Subject: Re: Using PROC COMPARE , comparing by sub group ( patient visit )
Content-Type: text/plain; charset="iso-8859-1"
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).
create table duplicates as
where visitid in(
group by visitid
having count(visitid) =2)
order by visitid;
data duplicates1 duplicates2;
if first.visitid then output duplicates1;
if last.visitid then output duplicates2;
ods trace on;
ods select CompareDifferences;
ods output CompareDifferences=CompareDifferences_set;
proc compare base=duplicates1
compare=duplicates2 NOMISSBASE NOMISSCOMP;
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.
----- Original Message -----
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?