LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 30 May 2008 13:54:27 -0500
Reply-To:     Mary <mlhoward@avalon.net>
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 )
Comments: To: idostatistics@GMAIL.COM
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).

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?


Back to: Top of message | Previous page | Main SAS-L page