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 is run-group processing?

616


how do you debug and test your sas programs? : Sas programming

558


I have a dataset concat having a variable a b & c. How to rename a b to e & f?

753


what is sas metadata server? : Sas-di

580


what are sas/access and sas/connect? : Sas programming

546






I am preparing SAS Certified Advanced Programmer for SAS 9 in 2014. If anybody has the latest dumps for this exam, please mail me at dhiman.mukherjee@gmail.com

2259


hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?

1656


Explain the purpose of substr functions in sas programming.

561


How would you invoke a macro? : sas-macro

543


What are the default statistics for means procedure?

635


How to convert a numeric variable to a character variable?

626


how will you location sas platform applications available from web browser? : Sas-bi

536


what is transformation in sas data integration? : Sas-di

541


Name validation tools used in SAS

685


Explain how merging helps to combine data sets.

607