## Help

Solved
Occasional Contributor
Posts: 7

# Help

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
Posts: 5,543

## Re: Help

proc sql;

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

quit;

PG

All Replies
Solution
‎04-12-2014 01:26 PM
Posts: 5,543

## Re: Help

proc sql;

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

quit;

PG
Occasional Contributor
Posts: 7

Thank you

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

Posts: 5,543

## 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: 10,787

## 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 and locked.