What is the difference between nodup and nodupkey options?

Answer Posted / majid

data test1;
input id1 $ id2 $ extra ;
cards;
aa ab 3
aa ab 1
aa ab 2
aa ab 3
;
proc sort nodup data=test1;
by id1 ;
run;
proc print data=test1;
run;
output will be like this:

Obs id1 id2 extra

1 aa ab 3
2 aa ab 1
3 aa ab 2
4 aa ab 3

*nodup" is an alias for "noduprecs" which appears to
mean "no duplicate records" but there is no way sas can
know about these duplicate records unless they, by chance,
land next to each other in sequence It is a big mistake
to think sorting "nodup" will remove duplicate records.
Sometime it will, sometime it won't. The only way you can
be sure of removing duplicate records is to "proc sort
nodupkey" and include enough key variables to be sure you
will lose the duplicates you want to lose. In the case
shown above, then if we knew of the same "extra" values
being duplicates we wanted to remove then this variable
should be included in the list of sort variables and
then "nodupkey" will remove the duplicates as shown below.
;
proc sort nodup data=test1;
by id1 id2 extra;
run;

proc print data=test1;
run;
output will be like this:

Obs id1 id2 extra

1 aa ab 1
2 aa ab 2
3 aa ab 3

so as u can see nodup eliminated all duplicate observations
if you sort them by all variables but nodupkey will show
only the duplicate observation.

proc sort nodupkey data=test1;
by id1 ;
run;
options nocenter;
proc print data=test1;
run;
output will be like this:

Obs id1 id2 extra

1 aa ab 3

Is This Answer Correct ?    22 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do the put and input function do?

768


Give some examples where proc report’s defaults are different than proc print’s defaults?

799


what is the difference between unique key and primary key? : Sas-di

812


Mention what are the data types does SAS contain?

902


How to convert a numeric variable to a character variable?

851


What system options would you use to help debug a macro? : sas-macro

850


Describe 5 ways to do a “table lookup” in SAS?

876


What is maximum number of rows and cols can be handled in SAS?

1055


What are the features of SAS?

777


what are validation tools that are used in sas? : Sas-administrator

810


Differentiate input and infile.

807


Define run-group processing?

779


what do the sas log messages "numeric values have been converted to character" mean? What are the implications? : Sas programming

895


how does sas handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, procs? : Sas programming

813


How to specify variables to be processed by the freq procedure?

824