@sasjs/core 2.56.0 → 2.57.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_existfeature.sas +1 -1
- package/base/mf_getattrc.sas +1 -1
- package/base/mf_getattrn.sas +1 -1
- package/base/mf_mkdir.sas +1 -1
- package/base/mf_nobs.sas +1 -1
- package/base/mp_copyfolder.sas +4 -2
- package/base/mp_ds2fmtds.sas +11 -4
- package/base/mp_ds2inserts.sas +1 -0
- package/base/mp_filtervalidate.sas +2 -2
- package/base/mp_getconstraints.sas +3 -3
- package/base/mp_getddl.sas +1 -1
- package/base/mp_hashdataset.sas +7 -2
- package/base/mp_init.sas +23 -12
- package/base/mp_jsonout.sas +1 -1
- package/base/mp_lockanytable.sas +1 -1
- package/base/mp_searchdata.sas +37 -26
- package/meta/mm_createwebservice.sas +1 -1
- package/package.json +1 -1
- package/viya/mv_createwebservice.sas +1 -1
- package/viya/mv_getfoldermembers.sas +1 -0
- package/viya/mv_jobwaitfor.sas +1 -0
package/base/mf_existfeature.sas
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Run without arguments to see a list of detectable features.
|
|
6
6
|
Note - this list is based on known versions of SAS rather than
|
|
7
7
|
actual feature detection, as that is tricky / impossible to do
|
|
8
|
-
without generating
|
|
8
|
+
without generating errs in most cases.
|
|
9
9
|
|
|
10
10
|
%put %mf_existfeature(PROCLUA);
|
|
11
11
|
|
package/base/mf_getattrc.sas
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
@param attr full list in [documentation](
|
|
11
11
|
https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000147794.htm)
|
|
12
12
|
@return output returns result of the attrc value supplied, or -1 and log
|
|
13
|
-
message if
|
|
13
|
+
message if err.
|
|
14
14
|
|
|
15
15
|
@version 9.2
|
|
16
16
|
@author Allan Bowe
|
package/base/mf_getattrn.sas
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
@param attr Common values are NLOBS and NVARS, full list in [documentation](
|
|
11
11
|
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212040.htm)
|
|
12
12
|
@return output returns result of the attrn value supplied, or -1 and log
|
|
13
|
-
message if
|
|
13
|
+
message if err.
|
|
14
14
|
|
|
15
15
|
@version 9.2
|
|
16
16
|
@author Allan Bowe
|
package/base/mf_mkdir.sas
CHANGED
package/base/mf_nobs.sas
CHANGED
package/base/mp_copyfolder.sas
CHANGED
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
/* create folders and copy content */
|
|
56
56
|
data _null_;
|
|
57
57
|
set work.&tempds;
|
|
58
|
+
length msg $256;
|
|
59
|
+
call missing(msg);
|
|
58
60
|
if _n_ = 1 then dpos+sum(length(directory),2);
|
|
59
61
|
filepath2="&target/"!!substr(filepath,dpos);
|
|
60
62
|
if file_or_folder='folder' then call execute('%mf_mkdir('!!filepath2!!')');
|
|
@@ -63,9 +65,9 @@
|
|
|
63
65
|
rc1=filename(fref1,filepath,'disk','recfm=n');
|
|
64
66
|
rc2=filename(fref2,filepath2,'disk','recfm=n');
|
|
65
67
|
if fcopy(fref1,fref2) ne 0 then do;
|
|
66
|
-
|
|
68
|
+
msg=sysmsg();
|
|
67
69
|
putlog "%str(ERR)OR: Unable to copy " filepath " to " filepath2;
|
|
68
|
-
putlog
|
|
70
|
+
putlog msg=;
|
|
69
71
|
end;
|
|
70
72
|
end;
|
|
71
73
|
rc=filename(fref1);
|
package/base/mp_ds2fmtds.sas
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
|
-
@brief Converts every value in a dataset to
|
|
3
|
+
@brief Converts every value in a dataset to formatted value
|
|
4
4
|
@details Converts every value to it's formatted value. All variables will
|
|
5
|
-
become character, and will be in the same order.
|
|
5
|
+
become character, and will be in the same order as the original dataset.
|
|
6
|
+
|
|
7
|
+
Lengths will be adjusted according to the format lengths, where applicable.
|
|
6
8
|
|
|
7
9
|
Usage:
|
|
8
10
|
|
|
9
11
|
%mp_ds2fmtds(sashelp.cars,work.cars)
|
|
12
|
+
%mp_ds2fmtds(sashelp.vallopt,vw_vallopt)
|
|
10
13
|
|
|
11
14
|
@param [in] libds The library.dataset to be converted
|
|
12
15
|
@param [out] outds The dataset to create.
|
|
13
16
|
|
|
17
|
+
<h4> SAS Macros </h4>
|
|
18
|
+
@li mf_existds.sas
|
|
19
|
+
|
|
14
20
|
<h4> Related Macros <h4>
|
|
15
21
|
@li mp_jsonout.sas
|
|
16
22
|
|
|
@@ -22,8 +28,9 @@
|
|
|
22
28
|
)/*/STORE SOURCE*/;
|
|
23
29
|
|
|
24
30
|
/* validations */
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
|
|
32
|
+
%if not %mf_existds(libds=&libds) %then %do;
|
|
33
|
+
%put %str(WARN)ING: &libds does not exist as either a VIEW or DATASET;
|
|
27
34
|
%return;
|
|
28
35
|
%end;
|
|
29
36
|
%if %index(&libds,.)=0 %then %let libds=WORK.&libds;
|
package/base/mp_ds2inserts.sas
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
@param [in] targetds The target dataset against which to verify the query
|
|
34
34
|
@param [out] abort= (YES) If YES will call mp_abort.sas on any exceptions
|
|
35
35
|
@param [out] outds= (work.mp_filtervalidate) Output dataset containing the
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
err / warning message, if one exists. If this table contains any rows,
|
|
37
|
+
there are problems!
|
|
38
38
|
|
|
39
39
|
<h4> SAS Macros </h4>
|
|
40
40
|
@li mf_getuniquefileref.sas
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
%let vw=%mf_getuniquename(prefix=mp_getconstraints_vw_);
|
|
49
49
|
data &vw /view=&vw;
|
|
50
50
|
set sashelp.vcncolu;
|
|
51
|
-
where
|
|
51
|
+
where table_catalog="&lib";
|
|
52
52
|
|
|
53
53
|
/* use retain approach to reset the constraint order with each constraint */
|
|
54
54
|
length tmp $1000;
|
|
55
55
|
retain tmp;
|
|
56
56
|
drop tmp;
|
|
57
|
-
if tmp ne catx('|',
|
|
57
|
+
if tmp ne catx('|',table_catalog,table_name,constraint_name) then do;
|
|
58
58
|
constraint_order=1;
|
|
59
59
|
end;
|
|
60
60
|
else constraint_order+1;
|
|
61
|
-
tmp=catx('|',
|
|
61
|
+
tmp=catx('|',table_catalog, table_name,constraint_name);
|
|
62
62
|
run;
|
|
63
63
|
|
|
64
64
|
/* must use SQL as proc datasets does not support length changes */
|
package/base/mp_getddl.sas
CHANGED
package/base/mp_hashdataset.sas
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
@param [in] libds dataset to hash
|
|
23
23
|
@param [in] salt= Provide a salt (could be, for instance, the dataset name)
|
|
24
|
+
@param [in] iftrue= A condition under which the macro should be executed.
|
|
24
25
|
@param [out] outds= (work.mf_hashdataset) The output dataset to create. This
|
|
25
26
|
will contain one column (hashkey) with one observation (a hex32.
|
|
26
27
|
representation of the input hash)
|
|
@@ -35,10 +36,14 @@
|
|
|
35
36
|
%macro mp_hashdataset(
|
|
36
37
|
libds,
|
|
37
38
|
outds=,
|
|
38
|
-
salt
|
|
39
|
+
salt=,
|
|
40
|
+
iftrue=%str(1=1)
|
|
39
41
|
)/*/STORE SOURCE*/;
|
|
42
|
+
|
|
43
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
44
|
+
|
|
40
45
|
%if %mf_getattrn(&libds,NLOBS)=0 %then %do;
|
|
41
|
-
%put %str(WARN)ING: Dataset &libds is empty
|
|
46
|
+
%put %str(WARN)ING: Dataset &libds is empty, or is not a dataset;
|
|
42
47
|
%end;
|
|
43
48
|
%else %if %mf_getattrn(&libds,NLOBS)<0 %then %do;
|
|
44
49
|
%put %str(ERR)OR: Dataset &libds is not a dataset;
|
package/base/mp_init.sas
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Initialise session with useful settings and variables
|
|
4
|
-
@details Implements a set of
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SAS-Powered applications elsewhere.
|
|
4
|
+
@details Implements a "strict" set of SAS options for use in defensive
|
|
5
|
+
programming. Highly recommended, if you want your code to run on some
|
|
6
|
+
other machine.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
This macro is recommended to be compiled and invoked in the `initProgram`
|
|
9
|
+
for SASjs [Jobs](https://cli.sasjs.io/sasjsconfig.html#jobConfig_initProgram
|
|
10
|
+
), [Services](
|
|
11
|
+
https://cli.sasjs.io/sasjsconfig.html#serviceConfig_initProgram) and [Tests]
|
|
12
|
+
(https://cli.sasjs.io/sasjsconfig.html#testConfig_initProgram).
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
For non SASjs projects, you could invoke in the autoexec, or in your own
|
|
15
|
+
solution initialisation macro.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
If you have a good idea for another useful option, setting, or global
|
|
19
|
+
variable - feel free to [raise an issue](
|
|
20
|
+
https://github.com/sasjs/core/issues/new)!
|
|
21
|
+
|
|
22
|
+
All global variables are prefixed with "SASJS" (unless modified with the
|
|
13
23
|
prefix parameter).
|
|
14
24
|
|
|
15
25
|
@param [in] prefix= (SASJS) The prefix to apply to the global macro variables
|
|
@@ -39,16 +49,17 @@
|
|
|
39
49
|
autocorrect /* disallow mis-spelled procedure names */
|
|
40
50
|
compress=CHAR /* default is none so ensure we have something! */
|
|
41
51
|
datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */
|
|
42
|
-
|
|
43
|
-
fmterr /* ensure
|
|
44
|
-
mergenoby
|
|
45
|
-
missing=.
|
|
52
|
+
%str(err)orcheck=STRICT /* catch errs in libname/filename statements */
|
|
53
|
+
fmterr /* ensure err when a format cannot be found */
|
|
54
|
+
mergenoby=%str(ERR)OR /* throw err when a merge has no BY variables */
|
|
55
|
+
missing=. /* changing this can cause hard to detect errs */
|
|
46
56
|
noquotelenmax /* avoid warnings for long strings */
|
|
47
57
|
noreplace /* avoid overwriting permanent datasets */
|
|
48
58
|
ps=max /* reduce log size slightly */
|
|
49
59
|
validmemname=COMPATIBLE /* avoid special characters etc in table names */
|
|
50
60
|
validvarname=V7 /* avoid special characters etc in variable names */
|
|
51
|
-
|
|
61
|
+
varinitchk=%str(ERR)OR /* avoid data mistakes from variable name typos */
|
|
62
|
+
varlenchk=%str(ERR)OR /* fail hard if truncation (data loss) can result */
|
|
52
63
|
;
|
|
53
64
|
|
|
54
65
|
%mend mp_init;
|
package/base/mp_jsonout.sas
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
%if &action=OPEN %then %do;
|
|
64
64
|
options nobomfile;
|
|
65
65
|
data _null_;file &jref encoding='utf-8';
|
|
66
|
-
put '{"
|
|
66
|
+
put '{"PROCESSED_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '"';
|
|
67
67
|
run;
|
|
68
68
|
%end;
|
|
69
69
|
%else %if (&action=ARR or &action=OBJ) %then %do;
|
package/base/mp_lockanytable.sas
CHANGED
|
@@ -239,7 +239,7 @@ run;
|
|
|
239
239
|
%let abortme=1;
|
|
240
240
|
%end;
|
|
241
241
|
|
|
242
|
-
/* catch
|
|
242
|
+
/* catch errs - mp_abort must be called outside of a logic block */
|
|
243
243
|
%mp_abort(iftrue=(&abortme=1),
|
|
244
244
|
msg=%superq(msg),
|
|
245
245
|
mac=&sysmacroname
|
package/base/mp_searchdata.sas
CHANGED
|
@@ -11,22 +11,28 @@
|
|
|
11
11
|
Usage:
|
|
12
12
|
|
|
13
13
|
%mp_searchdata(lib=sashelp, string=Jan)
|
|
14
|
-
%mp_searchdata(lib=sashelp, numval=1)
|
|
14
|
+
%mp_searchdata(lib=sashelp, ds=bird, numval=1)
|
|
15
|
+
%mp_searchdata(lib=sashelp, ds=class, string=l,outobs=5)
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
Outputs zero or more tables to an MPSEARCH library with specific records.
|
|
18
19
|
|
|
19
|
-
@param lib=
|
|
20
|
-
@param ds=
|
|
21
|
-
@param string=
|
|
22
|
-
@param numval=
|
|
23
|
-
@param outloc= the directory in which to
|
|
24
|
-
matching rows.
|
|
25
|
-
|
|
20
|
+
@param [in] lib= The libref to search (should be already assigned)
|
|
21
|
+
@param [in] ds= The dataset to search (leave blank to search entire library)
|
|
22
|
+
@param [in] string= String value to search (case sensitive, can be partial)
|
|
23
|
+
@param [in] numval= Numeric value to search (must be exact)
|
|
24
|
+
@param [out] outloc= (0) Optionally specify the directory in which to
|
|
25
|
+
create the the output datasets with matching rows. By default it will
|
|
26
|
+
write them to a temporary subdirectory within the WORK folder.
|
|
27
|
+
@param [out] outlib= (MPSEARCH) Assign a different libref to the output
|
|
28
|
+
library containing the matching datasets / records
|
|
29
|
+
@param [in] outobs= set to a positive integer to restrict the number of
|
|
26
30
|
observations
|
|
27
|
-
@param filter_text=
|
|
31
|
+
@param [in] filter_text= (1=1) Add a (valid) filter clause to further filter
|
|
32
|
+
the results.
|
|
28
33
|
|
|
29
34
|
<h4> SAS Macros </h4>
|
|
35
|
+
@li mf_getuniquename.sas
|
|
30
36
|
@li mf_getvarlist.sas
|
|
31
37
|
@li mf_getvartype.sas
|
|
32
38
|
@li mf_mkdir.sas
|
|
@@ -36,11 +42,12 @@
|
|
|
36
42
|
@author Allan Bowe
|
|
37
43
|
**/
|
|
38
44
|
|
|
39
|
-
%macro mp_searchdata(lib=
|
|
45
|
+
%macro mp_searchdata(lib=
|
|
40
46
|
,ds=
|
|
41
47
|
,string= /* the query will use a contains (?) operator */
|
|
42
48
|
,numval= /* numeric must match exactly */
|
|
43
|
-
,outloc
|
|
49
|
+
,outloc=0
|
|
50
|
+
,outlib=MPSEARCH
|
|
44
51
|
,outobs=-1
|
|
45
52
|
,filter_text=%str(1=1)
|
|
46
53
|
)/*/STORE SOURCE*/;
|
|
@@ -57,8 +64,12 @@
|
|
|
57
64
|
%if &string = %then %let type=N;
|
|
58
65
|
%else %let type=C;
|
|
59
66
|
|
|
67
|
+
%if "&outloc"="0" %then %do;
|
|
68
|
+
%let outloc=%sysfunc(pathname(work))/%mf_getuniquename();
|
|
69
|
+
%end;
|
|
70
|
+
|
|
60
71
|
%mf_mkdir(&outloc)
|
|
61
|
-
libname
|
|
72
|
+
libname &outlib "&outloc";
|
|
62
73
|
|
|
63
74
|
/* get the list of tables in the library */
|
|
64
75
|
proc sql noprint;
|
|
@@ -70,11 +81,6 @@ select distinct memname into: table_list separated by ' '
|
|
|
70
81
|
%end;
|
|
71
82
|
;
|
|
72
83
|
/* check that we have something to check */
|
|
73
|
-
proc sql
|
|
74
|
-
%if &outobs>-1 %then %do;
|
|
75
|
-
outobs=&outobs
|
|
76
|
-
%end;
|
|
77
|
-
;
|
|
78
84
|
%if %length(&table_list)=0 %then %put library &lib contains no tables!;
|
|
79
85
|
/* loop through each table */
|
|
80
86
|
%else %do table_num=1 %to %sysfunc(countw(&table_list,%str( )));
|
|
@@ -85,10 +91,10 @@ proc sql
|
|
|
85
91
|
%end;
|
|
86
92
|
%else %do;
|
|
87
93
|
%let check_tm=%sysfunc(datetime());
|
|
88
|
-
/*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
/* prep input */
|
|
95
|
+
data &outlib..&table;
|
|
96
|
+
set &lib..&table;
|
|
97
|
+
where %unquote(&filter_text) and ( 0
|
|
92
98
|
/* loop through columns */
|
|
93
99
|
%do colnum=1 %to %sysfunc(countw(&vars,%str( )));
|
|
94
100
|
%let col=%scan(&vars,&colnum,%str( ));
|
|
@@ -102,15 +108,20 @@ proc sql
|
|
|
102
108
|
or ("&col"n = &numval)
|
|
103
109
|
%end;
|
|
104
110
|
%end;
|
|
105
|
-
|
|
111
|
+
);
|
|
112
|
+
%if &outobs>-1 %then %do;
|
|
113
|
+
if _n_ > &outobs then stop;
|
|
114
|
+
%end;
|
|
115
|
+
run;
|
|
106
116
|
%put Search query for &table took
|
|
107
117
|
%sysevalf(%sysfunc(datetime())-&check_tm) seconds;
|
|
108
|
-
%if &
|
|
109
|
-
%put %str(
|
|
118
|
+
%if &syscc ne 0 %then %do;
|
|
119
|
+
%put %str(ERR)ROR: SYSCC=&syscc when processing &lib..&table;
|
|
110
120
|
%return;
|
|
111
121
|
%end;
|
|
112
|
-
%if %mf_nobs(
|
|
113
|
-
|
|
122
|
+
%if %mf_nobs(&outlib..&table)=0 %then %do;
|
|
123
|
+
proc sql;
|
|
124
|
+
drop table &outlib..&table;
|
|
114
125
|
%end;
|
|
115
126
|
%end;
|
|
116
127
|
%end;
|
|
@@ -95,7 +95,7 @@ data _null_;
|
|
|
95
95
|
put '%if &action=OPEN %then %do; ';
|
|
96
96
|
put ' options nobomfile; ';
|
|
97
97
|
put ' data _null_;file &jref encoding=''utf-8''; ';
|
|
98
|
-
put ' put ''{"
|
|
98
|
+
put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
|
|
99
99
|
put ' run; ';
|
|
100
100
|
put '%end; ';
|
|
101
101
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
package/package.json
CHANGED
|
@@ -243,7 +243,7 @@ data _null_;
|
|
|
243
243
|
put '%if &action=OPEN %then %do; ';
|
|
244
244
|
put ' options nobomfile; ';
|
|
245
245
|
put ' data _null_;file &jref encoding=''utf-8''; ';
|
|
246
|
-
put ' put ''{"
|
|
246
|
+
put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
|
|
247
247
|
put ' run; ';
|
|
248
248
|
put '%end; ';
|
|
249
249
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|