Date: Mon, 1 May 2000 17:04:07 -0400
Reply-To: "Roberson, Sheryll" <RobersonS@AETNA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Roberson, Sheryll" <RobersonS@AETNA.COM>
Subject: Re: Get duplicate records?
Another solution is:
Data MyData;
set MyData;
id_class = compress(id||class);
proc sort data=MyData;
by id_class;
Data MyData2;
Set MyData;
By id_class;
If not(first.id_class) or not(last.id_class)
then output;
Sheryll Roberson
U.S. Quality Algorithms-Houston
Strategic Healthcare Analysis
> * 713-350-2874
> * RobersonS@Aetna.com
-----Original Message-----
From: David L. Ward [mailto:dward@SASHELP.COM]
Sent: Monday, May 01, 2000 3:48 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Get duplicate records?
Here's the simplest way in my humble opinion (aka IMHO)
proc sort data=MyData;
by id class;
data MyData2;
set MyData;
by id class;
if first.class+last.class<2;
run;
Unique records have first.class and last.class equal to 1, all non-unique
records have something else (like first.class=0, last.class=1, or both zero,
etc.). So testing if the first and last indicator variables sum to 2 gives
you non-unique records by class.
HTH
David Ward
SASHelp.com (soon to be libname.com)
-----Original Message-----
From: Kathy White <kathyzhi@HOTMAIL.COM>
Sent: 5/1/00 7:03:20 PM
Subject: Get duplicate records?
> Suppose I have following dataset: MyData:
>
>ID Class grade
>001 100 A
>001 200 B
>001 300 A
>002 100 A
>002 100 B
>002 200 C
>003 100 A
>003 200 B
>003 300 A
>
>Right now, what I want to select is those who attened the same class twice.
>In this example, I want to get the student with ID=002. What is the most
>efficient way to do this? Any advice is appreciated in advance.
>Regards,
>Kathy
>
>
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
_____________________________________________________
Sent by SASHelp.com user David L. Ward
SASHelp.com - On-Line SAS Resources
Web interface to SAS-L at http://www.sashelp.com/sasl