Hello,
I'm looking to list all datasets in a library, variables and variable types along with the library name.
I've found this on this forum located here:https://communities.sas.com/t5/SAS-Procedures/PROC-CONTENTS-of-entire-library-with-all-variables-det...
Can someone please assist?
/* Note that value of libname is UPPERCASE */
proc sql;
create table columns as
select name as variable
,memname as table_name
from dictionary.columns
where libname = 'WORK'
;
quit;
* Change SASHELP with the library name;
PROC CONTENTS DATA=SASHELP._ALL_ ; RUN;
* Change SASHELP with the library name;
PROC CONTENTS DATA=SASHELP._ALL_ ; RUN;
It all depends on what you want to do with it. If you want to do some coding then the proc sql is better. I'm doing an automatic metadata documentation of all the libraries, tables, variables and formats by a combination of queries to the dictionary tables. But if you only need to view them on off, then the proc datasets is perfect.
proc sql;
create table columns as
select libname, memname, name, type, length, varnum
from dictionary.columns
where libname = upcase('WORK') ;
quit;
%macro printContents();
proc sql noprint;
*Get all the libraries that you want;
select cats(libname,".",memname) into : ds separated by " "
from dictionary.tables
where libname = upcase('SASHELP') and upcase(memname) in ("CLASS" "BASEBALL");
quit;
*Get the number of tables to loop.;
%let no_of_tables=%sysfunc(countw(&ds," "));
*Loop the list;
%do _i = 1 %to &no_of_tables;
%let ds_name=%scan(&ds,&_i, %str( ));
PROC CONTENTS DATA=&ds_name;
RUN;
%end;
%mend printContents;
%printContents();
Maybe this?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.