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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1382 views
  • 1 like
  • 5 in conversation