Hi all,
Could you please say what is the context in the "SORTEDBY=_NULL_" (unfortunately I can not ask the author) in the following code:
DATA test (SORTEDBY=_NULL_);
SET pretest;
RUN;
The dataset pretest was previously sorted by one variable.
Thank you!
As the SORTEDBY= Data Set Option Documentation says it "removes any existing sort indicator." 🙂
A small example demonstrates the option
data SomeData;
input x @@;
datalines;
3 2 5 1 6 4 8 5
;
proc sort data=SomeData;
by x;
run;
/* SAS knows that SomeData is sorted (Sorted=Yes) */
proc contents data=SomeData;
run;
/* Sortedby=_null_ forces SAS to forget the sort information (Sorted=No) */
data test(sortedby=_null_);
set SomeData;
run;
proc contents data=test;
run;
As the SORTEDBY= Data Set Option Documentation says it "removes any existing sort indicator." 🙂
A small example demonstrates the option
data SomeData;
input x @@;
datalines;
3 2 5 1 6 4 8 5
;
proc sort data=SomeData;
by x;
run;
/* SAS knows that SomeData is sorted (Sorted=Yes) */
proc contents data=SomeData;
run;
/* Sortedby=_null_ forces SAS to forget the sort information (Sorted=No) */
data test(sortedby=_null_);
set SomeData;
run;
proc contents data=test;
run;
Thank you, draycut. I just do not understand for what was it needed that "SAS to forget the sort information"...
In that step it is not needed since SAS will not be storing any SORTEDBY information for a dataset created in that way.
Perhaps they had a previous process that did generate the data in a sorted order and they wanted to force SAS to store the fact it was sorted. So they were in the habit of using the SORTEDBY= dataset option and instead of removing it totally they just set the list of variables to _NULL_.
Hi,
Taken from the documentation:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131184.htm
removes any existing sort indicator
Regards,
Amir.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: