BookmarkSubscribeRSS Feed
Saikiran_Mamidi
Obsidian | Level 7

suppose i am having data below

 

id    name$

1      a

1      a

2      b

2      b

3      c

4      d

 

Here i want duplicate records by using proc sql in output dataset directly?

 

i.e       id    name$

            1     a

             2    b

code and explanation required?hightly appreciated...thanks

 

 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Is it a strick requirement to do this in SQL?

 

data have;
input id name $;
datalines;
1 a
1 a
2 b
2 b
3 c
4 d
;

proc sql;
    create table want as
    select * from have
    group by id, name
    having count(*) gt 1;
quit;
ed_sas_member
Meteorite | Level 14

Hi @Saikiran_Mamidi 

In addition to PROC SQL, you can also easily do that using a PROC SORT with the NODUPKEY option.

You can output:

- a dataset with no duplicate records (out = )

- a dataset with duplicate records (dupout = )

proc sort data=have out=no_dupkey dupout=dupkey nodupkey;
	by _all_;
run;

Dataset 'no_dupkey'Dataset 'no_dupkey'Dataset 'dupkey'Dataset 'dupkey'

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 25. 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
  • 2 replies
  • 515 views
  • 3 likes
  • 3 in conversation