BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

Is there any way to delete exact duplicate records and write out only one recor from dulplicated set?

Say for example my infile has a set of exact 5 duplicate records and I want to delete other 4 and just write out 1 record.

thanks,
sasbase9
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Explore PROC SORT and DUPOUT= option.

Scott Barry
SBBWorks, Inc.
barheat
Fluorite | Level 6
Proc Sort with noduplicates option works.

proc sort data=dsname out=sorted noduplicates;
by var1 var2 ...;
run;

The noduplicates option removes records that are exactly the same in every variable.
The noidupkey option removes records where the by variables are the same.

Hope this helps.
deleted_user
Not applicable
proc sort data=x nodups dupsout=dup;
by id;
run;

Now the duplicate obs move to Dup dataset and x has the master
data_null__
Jade | Level 19
Are you sure?

What do you expect the output of this program to be?

[pre]
data have;
input a b c;
cards;
1 2 3
1 1 3
1 2 3
;;;;
run;
proc sort data=have nodup out=nodups;
by a;
run;
[/pre]

From the online doc.
[pre]
If you specify this option, then PROC SORT compares all variable values for each
observation to those for the previous observation that was written to the output data set.
If an exact match is found, then the observation is not written to the output data set.
[/pre]

It goes on to say using BY _ALL_ will result in the expected output...
deleted_user
Not applicable
Hi,
You can use the following code, if you are not deleting on the basis of any key:

proc sql noprint;
create table Temp2
as
(select * from Temp1
union select * from Temp1);
quit;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 5 replies
  • 728 views
  • 0 likes
  • 4 in conversation