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

My data looks like this:

 

ID  Var  Value

1  A       1

1  A       1     

1  B       2

1  B       3

2  A       4

2  B       5

 

I would like to output the duplicate observations for ID and Var:

 

ID  Var  Value

1  A       1

1  A       1

1  B       2

1  B       3

 

I've tried this:

 

proc sql;
create table want as
select distinct id, var, count(*)
from have
group by id, var
having count(*) > 1;
quit;

 

However, this gives me all the disinct records of id and var, not just the instances where they appear twice or more. It also leaves out the Value column, which I would like to keep:  

 

ID  Var 

1  A           

1  B      

1  B      

2  A      

2  B      

 

Could someone please help me with this? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Change your select statement to 

select *

from...

View solution in original post

1 REPLY 1
Reeza
Super User

Change your select statement to 

select *

from...

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 2102 views
  • 0 likes
  • 2 in conversation