Help

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Help

Hi all; Thanks in advance for your answers

My question is

how to choose the rows where eid occurring more than once?

data abc;

input eid name$ age;

cards;

100 ppp 26

100 ppp 26

100 ppp 25

101 qqq 32

102 qqw 31

102 qqq 32

104 yyy 53

102 xxx 51

;


Accepted Solutions
Solution
‎04-12-2014 01:26 PM
Respected Advisor
Posts: 4,659

Re: Help

proc sql;

select * from abc group by eid having count(*)>1;

quit;

PG

View solution in original post


All Replies
Solution
‎04-12-2014 01:26 PM
Respected Advisor
Posts: 4,659

Re: Help

proc sql;

select * from abc group by eid having count(*)>1;

quit;

PG
Occasional Contributor
Posts: 7

Re: Help

Thank you

PGStats
New Contributor
Posts: 3

Re: Help

proc sort data=abc;

  by eid;

run;

data abc1 eid(keep=eid);

  set abc;

  by eid;

  if first.eid=1 then count=0;

  count+1;

  if _N_ <> 1 and count>1 then output eid;

run;

proc sort data=eid nodupkey;

  by eid;

run;

data abc_op;

  merge abc(in=a) eid(in=b);

  by eid;

  if a=1 and b=1;

run;


Any other simple solutions of doing this in a data step ?


By

http://www.biginfoanalysis.com

Respected Advisor
Posts: 4,659

Re: Help

Sure.

proc sort data=abc; by eid; run;

data want;

set abc; by eid;

if not (first.eid and last.eid);

run;

proc print data=want noobs; run;

PG

PG
Super User
Posts: 9,691

Re: Help

data step version solution.

data abc;
input eid name$ age;
cards;
100 ppp 26
100 ppp 26
100 ppp 25
101 qqq 32
102 qqw 31
102 qqq 32
104 yyy 53
102 xxx 51
;
run;
proc sort data=abc;by eid;run;
data want;
 set abc;
 by eid;
 if not (first.eid and last.eid);
run;



Xia Keshan

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 210 views
  • 8 likes
  • 4 in conversation