Date: Thu, 28 Feb 2008 15:49:33 -0600
Reply-To: Mary <mlhoward@avalon.net>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary <mlhoward@AVALON.NET>
Subject: Re: Comparison of String variables
Content-Type: text/plain; charset="iso-8859-1"
Your idea sounds like a good one. Perhaps something like code like this (not tested):
data set1;
informat combined $2.;
set ...;
if id1 < id2 then
combined=trim(id1) || trim(id2);
else
combined=trim(id2) || trim(id1);
run;
proc sql;
select distinct combined
from set1
order by combined;
quit;
run;
----- Original Message -----
From: Vijayan Sundaram
To: SAS-L@LISTSERV.UGA.EDU
Sent: Thursday, February 28, 2008 3:08 PM
Subject: Comparison of String variables
I have data set which looks like this.
OBS_NUM ID1 ID2
-----------------
1 A B
2 B A
3 A C
4 A D
5 D A
I want to define the pairs (1,2) and (4,5) as duplicates and end up with
the following dataset
ID1 ID2
------------
A B
A C
A D
My intial idea was to create a new variable called ID which will have a
value of AB for both observations 1 and 2 and then do a nodup on the new
variable. To create the new variable, I need to compare the A against B
and find out which is first in the sort order.
Any ideas?
Thanks for the help