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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 957 views
  • 3 likes
  • 3 in conversation