BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mirisage
Obsidian | Level 7

Hi SAS Forum,

To show my proc sort question, I have taken the below data set from SUGI paper 037-30 of Britta Kelsey, and is acknowledged.

data best;

input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10;

datalines;

01 A CR 0

02 A PD 1

03 B PR 1

04 B CR 2

05 C SD 1

06 C SD 3

07 C PD 2

01 A CR 0

03 B PD 1

;

run;

I have seen in many papers nodupkey in proc sort is used like in mtheod 1 below but my boss is always using it

like in method 2.

I have checked using proc compare and found that identical resutls are produced by both methods.

Method 1:

proc sort data=best  nodupkey out=ex1;

by arm patient;

run;

Method 2:

proc sort data=best out=ex2 nodupkey;

by arm patient;

run;

proc compare base=ex1 compare=ex2; run;

Question:

1. Do both methods produce identical results for larger data sets too?

2. Which method is efficient?

Could some one help me.

Thanks

Mirisa

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

NODUPKEY is an option on the PROC SORT statement. The placement of it is simply a matter of coding style and this doesn't change what it does or affect processing efficiency at all.

As long as NODUPKEY is placed after PROC SORT it can go in any order with the DATA = and OUT = options.

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

Perhaps I'm blind, but I can't see any different methods.

Ordering of options does not impact performance, and nothing other as well.

Data never sleeps
SASKiwi
PROC Star

NODUPKEY is an option on the PROC SORT statement. The placement of it is simply a matter of coding style and this doesn't change what it does or affect processing efficiency at all.

As long as NODUPKEY is placed after PROC SORT it can go in any order with the DATA = and OUT = options.

Mirisage
Obsidian | Level 7

Hi SASKiwi and

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1762 views
  • 3 likes
  • 3 in conversation