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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

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