Help using Base SAS procedures

Data Step

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 440
Accepted Solution

Data Step

Hi guys,

I have  a dataset like this below:

id      type   Score
100   A        12

100   A         11

101   B         10

101   A          9

101   C          12

102   B          13

102   B           5

102   B          7

103   A           4

103   C            6

........

...........

 

 

and i need to exctract the IDs which  have different values of "type". In my case that would be id=101 and 103 but i got no clue how to approach it. Any hints  please?

 

Thx

 


Accepted Solutions
Solution
‎02-22-2016 08:19 PM
Super Contributor
Posts: 490

Re: Data Step

proc sql ;
select id
from have 
group by id
having count(distinct type)>1
;
quit;

View solution in original post


All Replies
Solution
‎02-22-2016 08:19 PM
Super Contributor
Posts: 490

Re: Data Step

proc sql ;
select id
from have 
group by id
having count(distinct type)>1
;
quit;
Super Contributor
Super Contributor
Posts: 440

Re: Data Step

thanks Mohamed_zaki

 

completly forgot about  "distinct"

 

Thanks a lot!

Super Contributor
Posts: 490

Re: Data Step

data want ;
set have;
by id;
retain ttype pflag;
if first.id then do;  ttype=type;  pflag=0; end;
else if (type ne ttype) and (pflag=0) then do; output; pflag=1;end;
keep id;
run;
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 407 views
  • 5 likes
  • 2 in conversation