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;
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();
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.