Published on :
Macro EXTERNAL

Metadata Search via Grep

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
The macro parses an input string (format `Key^Value`), extracts the key, constructs the full path to a target metadata file, and uses an external macro `%AHGrpipe` to execute a case-insensitive `grep` command. The search result is stored in a macro variable and displayed in the log.
Data Analysis

Type : EXTERNAL


The code interacts with an external text file (defined by the `dir` and `metafile` parameters) via system commands, not via SAS libraries.

1 Code Block
MACRO
Explanation :
Defines the `AHGshowmeta` macro. It parses the parameters, constructs the search command, and delegates execution to the `%AHGrpipe` macro. It depends on the global variable `&root3` and the `grep` system tool.
Copied!
1%macro AHGshowmeta(entry=,metafile=Mac.meta,dir=&root3/tools);
2 %local metaName thename thevalue;
3 %let thename=%scan(&entry,1,^);
4 %let thevalue=%scan(&entry,2,^);
5 %let metaName=&dir/&metafile;
6 %AHGrpipe(grep -i ^&thename\^ &metaName,rcrpipe);
7 %put ###;
8 %put &rcrpipe;
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.