Published on :
Macro SASHELP

AHGlibpath Macro - Retrieving the Physical Path of a Library

This code is also available in: Deutsch Español Français
This macro analyzes the provided library (or table) name. It excludes standard libraries (WORK, SASHELP, SASUSER). For other libraries, it queries the SASHELP.VLIBNAM view to extract the physical path and stores it in a specified macro variable. Note: The code seems to contain a variable inconsistency (&thedsn vs &lib) and potential syntax errors (%upcase(lib) instead of &lib).
Data Analysis

Type : SASHELP


Uses the SASHELP.VLIBNAM system view to read library metadata.

1 Code Block
DATA STEP
Explanation :
Macro definition. Conditional logic to determine the target libref. If it's not a default library, a DATA STEP _NULL_ is executed to read SASHELP.VLIBNAM and assign the path to the target macro variable via CALL SYMPUT.
Copied!
1%macro AHGlibpath(lib,into);
2%IF not %index(&thedsn,.) %THEN %let lib=Work;
3%ELSE %let lib=%scan(&lib,1,.);
4 
5%IF %upcase(lib)=WORK %THEN ;
6%ELSE %IF %upcase(lib)=SASHELP %THEN ;
7%ELSE %IF %upcase(lib)=SASUSER %THEN ;
8%ELSE
9%DO;
10DATA _null_;
11 SET sashelp.vlibnam(where=(upcase("&lib")=LIBNAME));
12 call symput("&into",path);
13RUN;
14%END;
15 
16%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.