Published on :
Macro SASHELP

Macro for Retrieving Table Names

This code is also available in: Deutsch Español Français
The `AHGlibMems` macro takes a library name (default 'work') and a destination macro variable name as input. It queries the `sashelp.vtable` system view to extract the names of tables associated with that library. The result is a list of concatenated names (format `lib.table`) separated by spaces, stored in the specified global macro variable.
Data Analysis

Type : SASHELP


Reading metadata via the standard `sashelp.vtable` system view.

1 Code Block
PROC SQL
Explanation :
Global declaration of the list variable. Use of PROC SQL to select and concatenate table names found in `sashelp.vtable` corresponding to the provided `libname`.
Copied!
1%macro AHGlibMems(lib=work,locallist=datalist);
2 %global &locallist;
3 PROC SQL noprint;
4 select compress("&lib.."||memname) into :&locallist separated BY ' '
5 from sashelp.vtable
6 where LIBNAME=upcase("&lib");
7 QUIT;
8
9%mend;
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.