Date: Thu, 9 Oct 2003 05:28:51 -0700
Reply-To: Tomislav Svoboda <tomislavtemp@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Tomislav Svoboda <tomislavtemp@HOTMAIL.COM>
Organization: http://groups.google.com
Subject: outputing observations that appear a specific number of times
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
I wrote code that outputs all observations or records that appear
twice. E.g. let's say you want to extract all records (e.g. with a key
of 2 variables) that appear 2 or more times. I'm wondering if there is
a better way of doing this (I bet SQL) or a more generalizable method
that can output those observations appearing any number of times e.g.
3 or (4 or more) etc...
thanks
Tomislav
data temp;
input a b c temp;
cards;
1 12 3 1
1 12 4 1
1 12 5 1
1 13 6 1
1 14 5 1
1 14 6 1
2 22 3 1
3 32 5 1
3 32 6 1
3 32 8 1
;
run;
proc sort;by a b;run;
data temp2;
set temp;
temp = 2;
run;
proc sort nodupkey; by a b;run;
data temp3;
merge temp temp2;
by a b;
if temp = 1;
flag = 1;
run;
data temp4;
merge temp temp3;
by a b;
if flag = 1;
run;
proc print;run;
|