BookmarkSubscribeRSS Feed
pavank
Quartz | Level 8

Hi Guys,

Good Evening

How to get sorted  datasets and notsorted datasets  list  in a library

2 REPLIES 2
Kathryn_SAS
SAS Employee

I am not sure if this is what you are asking, but in the output data set from PROC CONTENTS there is a SORTED variable. It will have a value of 1 if the data set is sorted or missing (.) if it is not. Here is a simple example.

proc sort data=sashelp.class out=class;
by age;
run;

proc sort data=sashelp.cars out=cars;
by type;
run;

data test;
x=1;
run;

proc contents data=work._all_ noprint out=allds(keep=libname memname sorted);
run;

data allds;
set allds;
by libname memname;
if first.memname then output;
run;

proc print data=allds;
run;
Quentin
Super User

Looks like you can pull this from dictionary.tables:

 

proc sql ;
  select memname, sortname, sorttype, sortchar
  from dictionary.tables 
  where libname="WORK" 
  ;
quit ;

See also this thread, which uses dictionary.columns : 
https://communities.sas.com/t5/SAS-Programming/Keeping-the-defined-sortedby-values-in-the-metadata/t...

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1317 views
  • 5 likes
  • 3 in conversation