Examples use generated data (datalines) or SASHELP data sets.
1 Code Block
DATA STEP / PROC CONTENTS Data
Explanation : This example uses the SORTEDBY= option to sort a 'sorttest' data set by 'priority' (descending) and 'indate'. Then, the PROC CONTENTS procedure is used to display the descriptive information of the sorted data set, including the sort indicator.
DATA sorttest (sortedby=priority descending indate);
2
INPUT priority indate date7. office $ code $;
3
FORMAT indate date7.;
4
DATALINES;
5
1 03may01 CH J8U
6
1 21mar01 LA M91
7
1 01dec00 FW L6R
8
1 27feb99 FW Q2A
9
2 15jan00 FW I9U
10
2 09jul99 CH P3Q
11
3 08apr99 CH H5T
12
3 31jan99 FW D2W
13
;
14
PROC CONTENTSDATA=sorttest; RUN;
2 Code Block
PROC CONTENTS
Explanation : This example uses the PROC CONTENTS procedure to display descriptive information for the SAShelp.Snacks data set. This includes the number of observations, observation length, last modification date of the data set, and other facts, as well as the attributes of individual variables.
Copied!
proc contents data=sashelp.snacks;
run;
1
PROC CONTENTSDATA=sashelp.snacks;
2
RUN;
3 Code Block
PROC CONTENTS
Explanation : This example shows displaying sort information for the Sashelp.Air data set using PROC CONTENTS. The 'Sorted' field indicates 'NO', meaning the data set is not sorted and no sort indicator table is present.
Copied!
proc contents data=sashelp.air; run;
1
PROC CONTENTSDATA=sashelp.air; RUN;
4 Code Block
DATA STEP / PROC CONTENTS
Explanation : This example creates an 'air' data set from 'sashelp.air' and uses the 'sortedby=air' option in the DATA statement. PROC CONTENTS is then executed, showing that the data set is now marked as sorted, but with 'Validated' as 'NO', because SORTEDBY= does not generate a SAS-validated sort.
Copied!
data air(sortedby=air);
set sashelp.air;
run;
proc contents data=air; run;
1
DATA air(sortedby=air);
2
SET sashelp.air;
3
RUN;
4
5
PROC CONTENTSDATA=air; RUN;
5 Code Block
PROC SORT / PROC CONTENTS
Explanation : This example sorts the 'air' data set by the 'air' variable in descending order using PROC SORT. Then, PROC CONTENTS is used to display the sort information, including the sort information table and the 'Validated' field set to 'YES', indicating a SAS-validated sort.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« In SAS, the sort indicator is a critical piece of metadata stored in the dataset descriptor. It acts as a "signal" to subsequent procedures (like PROC MEANS or MERGE) that the data is already ordered. Managing this indicator correctly is the key to bypassing redundant and resource-heavy sorting operations in large-scale production pipelines. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.