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
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;
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;
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!
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.