Published on :
Utility SASHELP

Dynamic Macro Execution on Metadata

This code is also available in: Deutsch Español Français
This program queries the `sashelp.vstabvw` system view to identify all tables or views whose name contains the string 'STAFF'. For each match, it uses `CALL EXECUTE` to invoke a macro named `%contents` (assumed to be defined elsewhere) on the identified table.
Data Analysis

Type : SASHELP


Metadata is read from the `sashelp.vstabvw` view.

1 Code Block
DATA STEP
Explanation :
Reads table metadata, filters those containing 'STAFF' and dynamically generates the execution of the %contents macro for each table found.
Copied!
1DATA _null_;
2 SET sashelp.vstabvw(keep=LIBNAME memname);
3 where memname contains "STAFF";
4 call execute(cats('%contents(data=', LIBNAME, ".", memname, ')' ));
5RUN;
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.