Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping only the duplicates

Tags:

sas

I'm trying to keep only the duplicate results for one column in a table. This is what I have.

proc sql; 
    create table DUPLICATES as 
    select Address, count(*) as count 
    from TEST_TABLE
    group by Address
    having COUNT gt 1 
    ;
quit;

Is there any easier way to do this or an alternative I didn't think of? It seems goofy that I then have to re-join it with the original table to get my answer.

like image 445
Skyler Avatar asked May 31 '26 05:05

Skyler


1 Answers

proc sort data=TEST_TABLE;
    by Address;
run;

data DUPLICATES;
    set TEST_TABLE;
    by Address;
    if not (first.Address and last.Address) then output;
run;
like image 71
DCWoods Avatar answered Jun 02 '26 20:06

DCWoods



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!