BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6
Hello Everyone,

I am trying to get rid of records with duplicate key (the by value in proc sort). I tried different syntax and could never get it to work. The field ID1 is the key. I want to have unique ID1 in the outfile.

I have used:
PROC SORT; BY ID1; NODUP;
PROC SORT; BY ID1 NODUP;

none of these work. Does anyone have any suggestion?

Thank you so much!
7 REPLIES 7
Flip
Fluorite | Level 6
PROC SORT; BY ID1; NODUPkey;
data_null__
Jade | Level 19
actually NODUPKEY is a PROC statement option.

[pre]
proc sort data=sashelp.class out=sex nodupkey;
by sex;
run;
[/pre]
KevinC_
Fluorite | Level 6
DATA_NULL,

That worked. Thank you so much!!
:)
KevinC_
Fluorite | Level 6
Thank you Flip.

I tried it with your exact syntax and got the following error:
"Statement is not valid or it is used out of proper order."

Any idea why? I am using sas version 8.2.

Thanks!
Flip
Fluorite | Level 6
Oops, yup
DanielSantos
Barite | Level 11
Very handy adresses...

Everything you wanted to know about SAS procedures:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/procwhatsnew902.htm#

And off course, the SAS Online documentation at:
http://support.sas.com/documentation/index.html

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, remember, for NODUP to work, the duplicate observations must be adjacent, which implicitly calls for a reasonably granular BY variable list when using the function. And, PROC SORT yields no mercy if you forget and code a BY variable list that will not achieve the required condition in order for the sort package to do its job removing duplicates.

Scott Barry
SBBWorks, Inc.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 965 views
  • 1 like
  • 5 in conversation