BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
mohamed_zaki
Barite | Level 11
proc sql ;
select id
from have 
group by id
having count(distinct type)>1
;
quit;

View solution in original post

3 REPLIES 3
mohamed_zaki
Barite | Level 11
proc sql ;
select id
from have 
group by id
having count(distinct type)>1
;
quit;
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thanks Mohamed_zaki

 

completly forgot about  "distinct"

 

Thanks a lot!

mohamed_zaki
Barite | Level 11
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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