01-08-2016 04:59 PM
I want to do a proc contents on many datasets(NOT ALL) within the same library.
I want something like this. Proc contents on all datasets in sashelp library starting with "c"
The below code definitely does not work.
proc contents data = sashelp.c : ;
How can I do this?
01-08-2016 10:39 PM
01-08-2016 11:29 PM
SASHELP.VTABLE exists always, as far as I know.
It might help your understanding of what this suggestion gives you if you view this table. It's essentially
PROC PRINT DATA=SASHELP.VTABLE;RUN;
Either way, you can modify the where statement to choose any assigned library you want. You could also get rid of the library='SASHELP' piece of the where statement altogether to see all tables in all libraries you have assigned. e.g.
data _null_; set sashelp.vtable; where memname=:'C'; call execute(cats('proc contents data=',libname,'.',memname,'; run;')); run;
01-09-2016 08:46 AM
It appears that I should have commented my suggestion a little more. Thanks to @JoshB for stepping in during the night (in my time zone).
Yes, the SET statement reading SASHELP.VTABLE is the constant part of the suggested data _null_ step. It was just coincidence that library SASHELP occurred in your example, too.
SASHELP.VTABLE is one of more than 30 SQL views on the so called DICTIONARY tables. These, in turn, are "special read-only PROC SQL tables or views [which] retrieve information about all the SAS libraries, SAS data sets, SAS system options, and external files that are associated with the current SAS session" (online documentation).
So, there is a lot of information, namely metadata, available through these views. As @Reeza suggested, the information you are looking for could most likely be retrieved directly from the DICTIONARY tables. This would be particularly convenient if you want to store or process those metadata.
However, if you just want to quickly look through selected PROC CONTENTS outputs on the screen, my suggested code should work well for you. Please note how flexible the WHERE condition is: You can filter by any combination of the 40+ variables in SASHELP.VTABLE, using operators and SAS functions to specify your selection criteria.
Example: If you are interested in the PROC CONTENTS outputs of all datasets
you could easily adapt the WHERE clause to match exactly these selection requirements (using variables
MEMTYPE, LIBNAME, MODATE, MEMNAME, MEMLABEL, FILESIZE, NOBS, NVAR, etc. of SASHELP.VTABLE).
As you can see, this goes far beyond what could be achieved with "wild cards in proc contents."
01-09-2016 01:13 PM