@sasjs/core 6.1.4 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mf_existvarlist.sas +16 -6
- package/package.json +1 -1
package/base/mf_existvarlist.sas
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Checks if a set of variables ALL exist in a data set.
|
|
4
|
-
@details Returns 0 if ANY of the variables do not exist,
|
|
4
|
+
@details Returns 0 if ANY of the variables do not exist, if the dataset
|
|
5
|
+
cannot be opened, if it holds no variables, or if `libds` / `varlist` is
|
|
6
|
+
blank. Returns 1 if they ALL exist. The macro never aborts: a blank input
|
|
7
|
+
answers 0 and the calling program decides whether that is a condition to
|
|
8
|
+
stop on (`mp_abort`) or simply a negative result.
|
|
5
9
|
Usage:
|
|
6
10
|
|
|
7
11
|
%put %mf_existVarList(sashelp.class, age sex name dummyvar);
|
|
@@ -9,9 +13,6 @@
|
|
|
9
13
|
@param [in] libds 2 part dataset or view reference
|
|
10
14
|
@param [in] varlist space separated variable names
|
|
11
15
|
|
|
12
|
-
<h4> SAS Macros </h4>
|
|
13
|
-
@li mf_abort.sas
|
|
14
|
-
|
|
15
16
|
@version 9.2
|
|
16
17
|
@author Allan Bowe
|
|
17
18
|
@cond
|
|
@@ -20,9 +21,12 @@
|
|
|
20
21
|
%macro mf_existvarlist(libds, varlist
|
|
21
22
|
)/*/STORE SOURCE*/;
|
|
22
23
|
|
|
24
|
+
/* nothing to check - answer 0 and let the caller decide whether a blank
|
|
25
|
+
input is a condition worth stopping on */
|
|
23
26
|
%if %str(&libds)=%str() or %str(&varlist)=%str() %then %do;
|
|
24
|
-
%
|
|
25
|
-
|
|
27
|
+
%put %str(WARN)ING: blank libds/varlist in mf_existvarlist;
|
|
28
|
+
0
|
|
29
|
+
%return;
|
|
26
30
|
%end;
|
|
27
31
|
|
|
28
32
|
%local dsid rc i var found;
|
|
@@ -30,10 +34,16 @@
|
|
|
30
34
|
|
|
31
35
|
%if &dsid=0 %then %do;
|
|
32
36
|
%put %str(WARN)ING: unable to open &libds in mf_existvarlist (&dsid);
|
|
37
|
+
/* the failed open reports through SYSMSG, not SYSERR or SYSCC, so the
|
|
38
|
+
return value is the whole signal - and ATTRN and VARNUM return a missing
|
|
39
|
+
value for dsid 0, which would report a match, so return before probing */
|
|
40
|
+
0
|
|
41
|
+
%return;
|
|
33
42
|
%end;
|
|
34
43
|
|
|
35
44
|
%if %sysfunc(attrn(&dsid,NVARS))=0 %then %do;
|
|
36
45
|
%put MF_EXISTVARLIST: No variables in &libds ;
|
|
46
|
+
%let rc=%sysfunc(close(&dsid));
|
|
37
47
|
0
|
|
38
48
|
%return;
|
|
39
49
|
%end;
|
package/package.json
CHANGED