forked from chris-swenson/sasmacros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexistlib.sas
55 lines (41 loc) · 1.59 KB
/
existlib.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%macro existlib(lib) / des="Check if libname exists";
/********************************************************************************
BEGIN MACRO HEADER
********************************************************************************
Name: existlib
Author: Chris Swenson
Created: 2019-07-01
Purpose: Check if libname exists
Arguments: lib - libname to check
Revisions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date Author Comments
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
YYYY-MM-DD III Please use this format and insert new entries above
********************************************************************************
END MACRO HEADER
********************************************************************************/
/* Set current mprint option and turn it off */
%local user_mprint;
%let user_mprint=%sysfunc(getoption(mprint));
options nomprint;
/* Assume libname does not exist */
%global nolib;
%let nolib=1;
/* Check for argument */
%if "&LIB"="" %then %do;
%put %str(E)RROR: Please specify a libname.;
%goto exit; /* Restore options and exit */
%end;
/* Check that the specified directory exists, if not change nolib */
%if %sysfunc(libref(&LIB))=0 %then %do;
%let nolib=0;
%put NOTE: The specified libname exists.;
%end;
%else %do;
%let nolib=1;
%put %str(E)RROR: The specified libname does not exist.;
%end;
%exit:
options &USER_MPRINT;
%mend existlib;