Help using Base SAS procedures

proc sort nodup

Reply
Regular Contributor
Posts: 173

proc sort nodup

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!
Super Contributor
Posts: 359

Re: proc sort nodup

PROC SORT; BY ID1; NODUPkey;
Respected Advisor
Posts: 3,799

Re: proc sort nodup

actually NODUPKEY is a PROC statement option.

[pre]
proc sort data=sashelp.class out=sex nodupkey;
by sex;
run;
[/pre]
Regular Contributor
Posts: 173

Re: proc sort nodup

Posted in reply to data_null__
DATA_NULL,

That worked. Thank you so much!!
Smiley Happy
Regular Contributor
Posts: 173

Re: proc sort nodup

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!
Super Contributor
Posts: 359

Re: proc sort nodup

Oops, yup
Super Contributor
Posts: 474

Re: proc sort nodup

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
Super Contributor
Super Contributor
Posts: 3,174

Re: proc sort nodup

Posted in reply to DanielSantos
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.
Ask a Question
Discussion stats
  • 7 replies
  • 179 views
  • 1 like
  • 5 in conversation