Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_islibds.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Checks whether a string follows correct library.dataset format
4 @details Many macros in the core library accept a library.dataset parameter
5 referred to as 'libds'. This macro validates the structure of that parameter,
6 eg:
7
8 @li 8 character libref?
9 @li 32 character dataset?
10 @li contains a period?
11
12 It does NOT check whether the dataset exists, or if the library is assigned.
13 The expression matches through the absolute end of the value: a trailing
14 newline is rejected. When the macro argument is supplied unquoted, SAS
15 macro processing strips a trailing LF before the value is validated, so
16 such a call is accepted; a macro-quoted trailing LF survives as a masked
17 byte and is rejected.
18
19 Usage:
20
21 %put %mf_islibds(work.something)=1;
22 %put %mf_islibds(nolib)=0;
23 %put %mf_islibds(badlibref.ds)=0;
24 %put %mf_islibds(w.t.f)=0;
25
26 @param [in] libds The string to be checked
27
28 @return output Returns 1 if libds is valid, 0 if it is not
29
30 <h4> Related Macros </h4>
31 @li mf_islibds.test.sas
32 @li mp_validatecol.sas
33
34 @version 9.2
35**/
36
37%macro mf_islibds(libds
38)/*/STORE SOURCE*/;
39
40%local regex;
41%let regex=%sysfunc(prxparse(%str(/^[_a-z]\w{0,7}\.[_a-z]\w{0,31}\z/i)));
42
43%sysfunc(prxmatch(&regex,&libds))
44
45%mend mf_islibds;