BookmarkSubscribeRSS Feed
jaliu
Quartz | Level 8

It seems like they are not automatically sorted based on the variable of the following column.

1 REPLY 1
Tom
Super User Tom
Super User

In general if there are repeated observations for a given set of values of the BY variables the order of those observations is not set.  

In practice PROC SORT would historically return them in the same order they were found in the input dataset, mainly as a side effect of processing the data sequentially.  With the multi-threaded sorting in more recent implementations of SAS preserving this order requires extra work.  So SAS has added an option that will allow you say you don't care if the input order is preserved.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p02bhn81rn4u64n1b6l00ftdnxge.htm#n0cuj0z...

 

EQUALS | NOEQUALS

specifies the order of the observations in the output data set. For observations with identical BY-variable values, EQUALS maintains the relative order of the observations within the input data set in the output data set. NOEQUALS does not necessarily preserve this order in the output data set.

Default EQUALS
Interactions When you use NODUPKEY to remove observations in the output data set, the choice of EQUALS or NOEQUALS can affect which observations are removed.
The EQUALS | NOEQUALS procedure option overrides the default sort stability behavior that is established with the SORTEQUALS | NOSORTEQUALS system option.
The EQUALS option is supported by the threaded sort. However, I/O performance might be reduced when using the EQUALS option with the threaded sort because partitioned data sets are processed as if they consist of a single partition.
The NOEQUALS option is supported by the threaded sort. The order of observations within BY groups that are returned by the threaded sort might not be consistent between runs.
Tip Using NOEQUALS can save CPU time and memory.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 672 views
  • 0 likes
  • 2 in conversation