@sasjs/core 5.2.9 → 5.3.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_getvalue.sas +24 -9
- package/base/mp_assertcols.sas +4 -2
- package/package.json +1 -1
package/base/mf_getvalue.sas
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
@file
|
|
3
3
|
@brief Retrieves a value from a dataset. Returned value is fetched from the
|
|
4
4
|
'fetchobs=' record (row 1 by default), after applying the optional filter.
|
|
5
|
+
Returns a vartype-specific missing value if no row is returned.
|
|
5
6
|
|
|
6
7
|
@details Be sure to <code>%quote()</code> your where clause. Example usage:
|
|
7
8
|
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
%put %mf_getvalue(sashelp.class,name);
|
|
10
11
|
|
|
11
12
|
<h4> SAS Macros </h4>
|
|
12
|
-
@li
|
|
13
|
+
@li mf_getvartype.sas
|
|
13
14
|
|
|
14
15
|
<h4> Related Macros </h4>
|
|
15
16
|
@li mp_setkeyvalue.sas
|
|
@@ -18,27 +19,41 @@
|
|
|
18
19
|
@param [in] variable the variable which contains the value to return.
|
|
19
20
|
@param [in] filter= (1) contents of where clause
|
|
20
21
|
@param [in] fetchobs= (1) observation to fetch. NB: Filter applies first.
|
|
22
|
+
@param [in] warn= (0) Set to 1 to raise a w@rning log message on attempt to
|
|
23
|
+
read past end of the input dataset.
|
|
24
|
+
|
|
21
25
|
|
|
22
26
|
@version 9.2
|
|
23
27
|
@author Allan Bowe
|
|
24
28
|
**/
|
|
25
29
|
|
|
26
|
-
%macro mf_getvalue(libds,variable,filter=1,fetchobs=1
|
|
30
|
+
%macro mf_getvalue(libds,variable,filter=1,fetchobs=1,warn=0
|
|
27
31
|
)/*/STORE SOURCE*/;
|
|
28
|
-
%local dsid;
|
|
32
|
+
%local dsid rc vartype;
|
|
33
|
+
|
|
34
|
+
%let vartype = %mf_getvartype(&libds,&variable);
|
|
29
35
|
|
|
30
36
|
%let dsid=%sysfunc(open(&libds(where=(&filter))));
|
|
31
37
|
%if (&dsid) %then %do;
|
|
32
|
-
%local rc &variable;
|
|
33
38
|
%syscall set(dsid);
|
|
34
39
|
%let rc = %sysfunc(fetchobs(&dsid,&fetchobs));
|
|
35
40
|
%if (&rc ne 0) %then %do;
|
|
36
|
-
%put NOTE: Problem reading obs &fetchobs from &libds..;
|
|
37
41
|
%put %sysfunc(sysmsg());
|
|
38
|
-
/*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
%if &
|
|
42
|
+
/* Set the requested variable to a missing value */
|
|
43
|
+
/* Need only consider numerics - char variables are already empty*/
|
|
44
|
+
%if (&vartype eq N) %then %let &variable = .;
|
|
45
|
+
%if (&warn) %then %do;
|
|
46
|
+
%if (&rc eq -1) %then %do; /* read past end of data */
|
|
47
|
+
%put %sysfunc(
|
|
48
|
+
compbl(
|
|
49
|
+
%quote(WARN%str(ING): Missing value returned as no rows were)
|
|
50
|
+
%quote(found in &libds for filter (%superq(filter)))
|
|
51
|
+
%quote(and/or fetchobs (&fetchobs).)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
%let rc=4;
|
|
55
|
+
%end;
|
|
56
|
+
%end;
|
|
42
57
|
/* And update SYSCC if the &rc value is higher */
|
|
43
58
|
%let syscc = %sysfunc(max(&syscc,&rc));
|
|
44
59
|
%end;
|
package/base/mp_assertcols.sas
CHANGED
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
@param [in] desc= (0) The user provided test description
|
|
36
36
|
@param [in] test= (ALL) The test to apply. Valid values are:
|
|
37
37
|
@li ALL - Test is a PASS if ALL columns exist in &inds
|
|
38
|
-
@li ANY - Test is a PASS if ANY of the columns exist in &inds
|
|
38
|
+
@li ANY - Test is a PASS if ANY of the columns exist in &inds - including
|
|
39
|
+
when all of them do
|
|
39
40
|
@li NONE - Test is a PASS if NONE of the columns exist in &inds
|
|
40
41
|
@param [out] outds= (work.test_results) The output dataset to contain the
|
|
41
42
|
results. If it does not exist, it will be created, with the following format:
|
|
@@ -121,7 +122,8 @@
|
|
|
121
122
|
%end;
|
|
122
123
|
%end;
|
|
123
124
|
%else %if &test=ANY %then %do;
|
|
124
|
-
|
|
125
|
+
/* SOME or ALL - if every column exists then any of them does too */
|
|
126
|
+
%if &result ne NONE %then %do;
|
|
125
127
|
test_result='PASS';
|
|
126
128
|
%end;
|
|
127
129
|
%end;
|
package/package.json
CHANGED