Date: Wed, 15 Sep 2010 10:30:16 -0700
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: A data step question: comparison of values of multiple
variables
In-Reply-To: A<201009151704.o8FGSYvA002492@willow.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Hi Daixin,
Here is one approach:
data sample;
infile cards missover;
input PATIENT_ID _01 _02 _03
_04 _05 _06 _07 _08 _09;
cards;
001 8310
002 3510 8310
003 7500
004 1010
005 6910 8310
006 . 8310
007 0600
008 2100 2100
009 8000 8000 8000
010 . 3500
;
run;
proc transpose data=sample out=temp1;
by PATIENT_ID;
var _:;
run;
proc sql;
create table diffs as
select PATIENT_ID
from temp1
where col1 ne .
group by PATIENT_ID
having count(distinct col1) gt 1
;
quit;
Hope this is helpful.
Mark Terjeson
Investment Business Intelligence
Investment Management & Research
Russell Investments
253-439-2367
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Daixin Yin
Sent: Wednesday, September 15, 2010 10:04 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: A data step question: comparison of values of multiple
variables
Hi there,
I have a quesion about comparing values of multiple variables within an
observation.
Here's how my dataset looks like:
PATIENT_ID _01 _02 _03 _04 _00 _05 _07 _60 _06 _08 _09
-----------------------------------------------------------------------
001 8310
002 3510 8310
003 7500
004 1010
005 6910 8310
006 8310
007 0600
008 2100 2100
009 8000 8000 8000
010 3500
Each observation has at least one non-missing value in variable _00 to
_60. I want to identify observations that had unequal values in variable
_00 to _60, such as PATIENT_ID 002 and 005 in the above sample dataset.
I believe that there must be more than one easy and efficient way to do.
Thanks for your help!!