@sasjs/core 4.1.0 → 4.2.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/README.md +2 -2
- package/base/mp_createwebservice.sas +10 -8
- package/base/mp_deletefolder.sas +1 -0
- package/base/mp_dirlist.sas +9 -2
- package/base/mp_ds2csv.sas +119 -14
- package/base/mp_init.sas +5 -3
- package/base/mp_jsonout.sas +6 -1
- package/base/mp_stackdiffs.sas +20 -24
- package/base/mp_testservice.sas +25 -11
- package/meta/mm_createstp.sas +1 -0
- package/meta/mm_createwebservice.sas +6 -1
- package/meta/mm_getservercontexts.sas +11 -4
- package/package.json +1 -1
- package/viya/mv_createwebservice.sas +6 -1
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ When contributing to this library, it is therefore important to ensure that all
|
|
|
181
181
|
- The closing `%mend;` should **not** contain the macro name.
|
|
182
182
|
- All macros should be defined with brackets, even if no variables are needed - ie `%macro x();` not `%macro x;`
|
|
183
183
|
- Mandatory parameters should be positional, all optional parameters should be keyword (var=) style.
|
|
184
|
-
- All dataset references must be 2 level (eg `work.blah`, not `blah`). This is to avoid contention when options [DATASTMTCHK](https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279064.htm)=ALLKEYWORDS is in effect.
|
|
184
|
+
- All dataset references must be 2 level (eg `work.blah`, not `blah`). This is to avoid contention when options [DATASTMTCHK](https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279064.htm)=ALLKEYWORDS is in effect, or the [USER](https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/n18m1vkqmeo4esn1moikt23zhp8s.htm) library is active.
|
|
185
185
|
- Avoid naming collisions! All macro variables should be local scope. Use system generated work tables where possible - eg `data ; set sashelp.class; run; data &output; set &syslast; run;`
|
|
186
186
|
- Where global macro variables are absolutely necessary, they should make use of `&sasjs_prefix` - see mp_init.sas
|
|
187
187
|
- The use of `quit;` for `proc sql` is optional unless you are looking to benefit from the timing statistics.
|
|
@@ -195,7 +195,7 @@ When contributing to this library, it is therefore important to ensure that all
|
|
|
195
195
|
|
|
196
196
|
We are currently on major release v4. Breaking changes should be marked with the [deprecated](https://www.doxygen.nl/manual/commands.html#cmddeprecated) doxygen tag. The following changes are planned when the next major (breaking) release becomes necessary:
|
|
197
197
|
|
|
198
|
-
*
|
|
198
|
+
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
|
199
199
|
|
|
200
200
|
## Star Gazing
|
|
201
201
|
|
|
@@ -24,20 +24,22 @@ Usage:
|
|
|
24
24
|
%webout(OBJ,example2) * Object format, easier to work with ;
|
|
25
25
|
%webout(CLOSE)
|
|
26
26
|
;;;;
|
|
27
|
-
%mp_createwebservice(path=/Public/app/common,name=appInit,
|
|
27
|
+
%mp_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
|
28
28
|
|
|
29
29
|
<h4> SAS Macros </h4>
|
|
30
30
|
@li mf_getplatform.sas
|
|
31
31
|
@li mm_createwebservice.sas
|
|
32
32
|
@li mv_createwebservice.sas
|
|
33
33
|
|
|
34
|
-
@param path= The full folder path where the service will be created
|
|
35
|
-
@param name= Service name. Avoid spaces.
|
|
36
|
-
@param desc= The description of the service (optional)
|
|
37
|
-
@param precode= Space separated list of filerefs, pointing to the code
|
|
38
|
-
needs to be attached to the beginning of the service (optional)
|
|
39
|
-
@param code= Space seperated fileref(s) of the actual code to
|
|
40
|
-
|
|
34
|
+
@param [in,out] path= The full folder path where the service will be created
|
|
35
|
+
@param [in,out] name= Service name. Avoid spaces.
|
|
36
|
+
@param [in] desc= The description of the service (optional)
|
|
37
|
+
@param [in] precode= Space separated list of filerefs, pointing to the code
|
|
38
|
+
that needs to be attached to the beginning of the service (optional)
|
|
39
|
+
@param [in] code= (ft15f001) Space seperated fileref(s) of the actual code to
|
|
40
|
+
be added
|
|
41
|
+
@param [in] replace= (YES) Select YES to replace any existing service in that
|
|
42
|
+
location
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
@version 9.2
|
package/base/mp_deletefolder.sas
CHANGED
package/base/mp_dirlist.sas
CHANGED
|
@@ -82,7 +82,8 @@ data &out_ds(compress=no
|
|
|
82
82
|
keep=file_or_folder filepath filename ext msg directory level
|
|
83
83
|
);
|
|
84
84
|
length directory filepath $500 fref fref2 $8 file_or_folder $6 filename $80
|
|
85
|
-
ext $20 msg $200;
|
|
85
|
+
ext $20 msg $200 foption $16;
|
|
86
|
+
if _n_=1 then call missing(of _all_);
|
|
86
87
|
retain level &level;
|
|
87
88
|
%if &fref=0 %then %do;
|
|
88
89
|
rc = filename(fref, "&path");
|
|
@@ -93,7 +94,13 @@ data &out_ds(compress=no
|
|
|
93
94
|
%end;
|
|
94
95
|
if rc = 0 then do;
|
|
95
96
|
did = dopen(fref);
|
|
96
|
-
|
|
97
|
+
/* attribute is OS-dependent - could be "Directory" or "Directory Name" */
|
|
98
|
+
numopts=doptnum(did);
|
|
99
|
+
do i=1 to numopts;
|
|
100
|
+
foption=doptname(did,i);
|
|
101
|
+
if foption=:'Directory' then i=numopts;
|
|
102
|
+
end;
|
|
103
|
+
directory=dinfo(did,foption);
|
|
97
104
|
if did=0 then do;
|
|
98
105
|
putlog "NOTE: This directory is empty - " directory;
|
|
99
106
|
msg=sysmsg();
|
package/base/mp_ds2csv.sas
CHANGED
|
@@ -1,23 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
|
-
@brief Export a dataset to a CSV file
|
|
4
|
-
@details Export to a file or
|
|
3
|
+
@brief Export a dataset to a CSV file WITH leading blanks
|
|
4
|
+
@details Export a dataset to a file or fileref, retaining leading blanks.
|
|
5
|
+
|
|
5
6
|
Usage:
|
|
6
7
|
|
|
7
8
|
%mp_ds2csv(sashelp.class,outref="%sysfunc(pathname(work))/file.csv")
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Why use mp_ds2csv over, say, proc export?
|
|
11
|
+
|
|
12
|
+
1. Ability to retain leading blanks (this is a major one)
|
|
13
|
+
2. Control the header format
|
|
14
|
+
3. Simple one-liner
|
|
15
|
+
|
|
16
|
+
@param [in] ds The dataset to be exported
|
|
17
|
+
@param [in] dlm= (COMMA) The delimeter to apply. For SASJS, will always be
|
|
18
|
+
COMMA. Supported values:
|
|
19
|
+
@li COMMA
|
|
20
|
+
@li SEMICOLON
|
|
21
|
+
@param [in] headerformat= (LABEL) The format to use for the header section.
|
|
22
|
+
Valid values:
|
|
23
|
+
@li LABEL - Use the variable label (or name, if blank)
|
|
24
|
+
@li NAME - Use the variable name
|
|
25
|
+
@li SASJS - Used to create sasjs-formatted input CSVs, eg for use in
|
|
26
|
+
mp_testservice.sas
|
|
27
|
+
@param [out] outfile= The output filename - should be quoted.
|
|
28
|
+
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
|
29
|
+
@param [in] outencoding= (0) The output encoding to use (unquoted)
|
|
30
|
+
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
|
31
|
+
always be CRLF. Valid values:
|
|
32
|
+
@li CRLF
|
|
33
|
+
@li LF
|
|
34
|
+
|
|
35
|
+
<h4> SAS Macros </h4>
|
|
36
|
+
@li mf_getuniquename.sas
|
|
37
|
+
@li mf_getvarlist.sas
|
|
38
|
+
@li mf_getvartype.sas
|
|
13
39
|
|
|
14
40
|
@version 9.2
|
|
15
41
|
@author Allan Bowe (credit mjsq)
|
|
16
42
|
**/
|
|
17
43
|
|
|
18
|
-
%macro mp_ds2csv(ds
|
|
44
|
+
%macro mp_ds2csv(ds
|
|
45
|
+
,dlm=COMMA
|
|
46
|
+
,outref=0
|
|
47
|
+
,outfile=
|
|
48
|
+
,outencoding=0
|
|
49
|
+
,headerformat=LABEL
|
|
50
|
+
,termstr=CRLF
|
|
19
51
|
)/*/STORE SOURCE*/;
|
|
20
52
|
|
|
53
|
+
%local outloc delim i varlist var vcnt vat dsv vcom vmiss;
|
|
54
|
+
|
|
21
55
|
%if not %sysfunc(exist(&ds)) %then %do;
|
|
22
56
|
%put %str(WARN)ING: &ds does not exist;
|
|
23
57
|
%return;
|
|
@@ -28,31 +62,102 @@
|
|
|
28
62
|
%if &outencoding=0 %then %let outencoding=;
|
|
29
63
|
%else %let outencoding=encoding="&outencoding";
|
|
30
64
|
|
|
31
|
-
%local outloc;
|
|
32
65
|
%if &outref=0 %then %let outloc=&outfile;
|
|
33
66
|
%else %let outloc=&outref;
|
|
34
67
|
|
|
68
|
+
%if &headerformat=SASJS %then %do;
|
|
69
|
+
%let delim=",";
|
|
70
|
+
%let termstr=CRLF;
|
|
71
|
+
%end;
|
|
72
|
+
%else %if &dlm=COMMA %then %let delim=",";
|
|
73
|
+
%else %let delim=";";
|
|
74
|
+
|
|
35
75
|
/* credit to mjsq - https://stackoverflow.com/a/55642267 */
|
|
36
76
|
|
|
37
77
|
/* first get headers */
|
|
38
78
|
data _null_;
|
|
39
|
-
file &outloc
|
|
40
|
-
length header $ 2000;
|
|
79
|
+
file &outloc &outencoding lrecl=32767 termstr=&termstr;
|
|
80
|
+
length header $ 2000 varnm $32 dlm $1;
|
|
41
81
|
dsid=open("&ds.","i");
|
|
42
82
|
num=attrn(dsid,"nvars");
|
|
83
|
+
dlm=&delim;
|
|
43
84
|
do i=1 to num;
|
|
44
|
-
|
|
85
|
+
varnm=upcase(varname(dsid,i));
|
|
86
|
+
if i=num then dlm='';
|
|
87
|
+
%if &headerformat=NAME %then %do;
|
|
88
|
+
header=cats(varnm,dlm);
|
|
89
|
+
%end;
|
|
90
|
+
%else %if &headerformat=LABEL %then %do;
|
|
91
|
+
header = cats(coalescec(varlabel(dsid,i),varnm),dlm);
|
|
92
|
+
%end;
|
|
93
|
+
%else %if &headerformat=SASJS %then %do;
|
|
94
|
+
if vartype(dsid,i)='C' then header=cats(varnm,':$char',varlen(dsid,i),'.');
|
|
95
|
+
else header=cats(varnm,':best.');
|
|
96
|
+
%end;
|
|
97
|
+
%else %do;
|
|
98
|
+
%put &sysmacroname: Invalid headerformat value (&headerformat);
|
|
99
|
+
%return;
|
|
100
|
+
%end;
|
|
45
101
|
put header @;
|
|
46
102
|
end;
|
|
47
103
|
rc=close(dsid);
|
|
48
104
|
run;
|
|
49
105
|
|
|
106
|
+
%let varlist=%mf_getvarlist(&ds);
|
|
107
|
+
%let vcnt=%sysfunc(countw(&varlist));
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The $quote modifier (without a width) will take the length from the variable
|
|
111
|
+
* and increase by two. However this will lead to truncation where the value
|
|
112
|
+
* contains double quotes (which are doubled up). To get around this, scan the
|
|
113
|
+
* data to see the max number of double quotes, so that the appropriate width
|
|
114
|
+
* can be applied in the subsequent step.
|
|
115
|
+
*/
|
|
116
|
+
data _null_;
|
|
117
|
+
set &ds end=last;
|
|
118
|
+
%do i=1 %to &vcnt;
|
|
119
|
+
%let var=%scan(&varlist,&i);
|
|
120
|
+
%if %mf_getvartype(&ds,&var)=C %then %do;
|
|
121
|
+
%let dsv1=%mf_getuniquename(prefix=csvcol1_);
|
|
122
|
+
%let dsv2=%mf_getuniquename(prefix=csvcol2_);
|
|
123
|
+
retain &dsv1 0;
|
|
124
|
+
&dsv2=length(&var)+countc(&var,'"');
|
|
125
|
+
if &dsv2>&dsv1 then &dsv1=&dsv2;
|
|
126
|
+
if last then call symputx(
|
|
127
|
+
"vlen&i"
|
|
128
|
+
/* should be no shorter than varlen, and no longer than 32767 */
|
|
129
|
+
,cats('$quote',min(&dsv1+2,32767),'.')
|
|
130
|
+
,'l'
|
|
131
|
+
);
|
|
132
|
+
%end;
|
|
133
|
+
%end;
|
|
134
|
+
|
|
135
|
+
%let vat=@;
|
|
136
|
+
%let vcom=&delim;
|
|
137
|
+
%let vmiss=%mf_getuniquename(prefix=csvcol3_);
|
|
50
138
|
/* next, export data */
|
|
51
139
|
data _null_;
|
|
52
140
|
set &ds.;
|
|
53
|
-
file &outloc mod dlm
|
|
54
|
-
|
|
141
|
+
file &outloc mod dlm=&delim dsd &outencoding lrecl=32767 termstr=&termstr;
|
|
142
|
+
if _n_=1 then &vmiss=' ';
|
|
143
|
+
%do i=1 %to &vcnt;
|
|
144
|
+
%let var=%scan(&varlist,&i);
|
|
145
|
+
%if &i=&vcnt %then %do;
|
|
146
|
+
%let vat=;
|
|
147
|
+
%let vcom=;
|
|
148
|
+
%end;
|
|
149
|
+
%if %mf_getvartype(&ds,&var)=N %then %do;
|
|
150
|
+
/* must use period - in order to work in both 9.4 and Viya 3.5 */
|
|
151
|
+
if missing(&var) and &var ne %sysfunc(getoption(MISSING)) then do;
|
|
152
|
+
&vmiss=cats('.',&var);
|
|
153
|
+
put &vmiss &vat;
|
|
154
|
+
end;
|
|
155
|
+
else put &var &vat;
|
|
156
|
+
%end;
|
|
157
|
+
%else %do;
|
|
158
|
+
put &var &&vlen&i &vcom &vat;
|
|
159
|
+
%end;
|
|
160
|
+
%end;
|
|
55
161
|
run;
|
|
56
162
|
|
|
57
|
-
|
|
58
163
|
%mend mp_ds2csv;
|
package/base/mp_init.sas
CHANGED
|
@@ -53,11 +53,9 @@ data _null_;
|
|
|
53
53
|
run;
|
|
54
54
|
|
|
55
55
|
options
|
|
56
|
-
noautocorrect /* disallow misspelled procedure names */
|
|
57
56
|
compress=CHAR /* default is none so ensure we have something! */
|
|
58
57
|
datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */
|
|
59
|
-
|
|
60
|
-
%str(err)orcheck=STRICT /* catch errs in libname/filename statements */
|
|
58
|
+
errorcheck=STRICT /* catch errs in libname/filename statements */
|
|
61
59
|
fmterr /* ensure err when a format cannot be found */
|
|
62
60
|
mergenoby=%str(ERR)OR /* throw err when a merge has no BY variables */
|
|
63
61
|
missing=. /* changing this can cause hard to detect errs */
|
|
@@ -69,6 +67,10 @@ options
|
|
|
69
67
|
validvarname=V7 /* avoid special characters etc in variable names */
|
|
70
68
|
varinitchk=%str(ERR)OR /* avoid data mistakes from variable name typos */
|
|
71
69
|
varlenchk=%str(ERR)OR /* fail hard if truncation (data loss) can result */
|
|
70
|
+
%if %substr(&sysver,1,1) ne 4 %then %do;
|
|
71
|
+
noautocorrect /* disallow misspelled procedure names */
|
|
72
|
+
dsoptions=note2err /* undocumented - convert bad NOTEs to ERRs */
|
|
73
|
+
%end;
|
|
72
74
|
;
|
|
73
75
|
|
|
74
76
|
%mend mp_init;
|
package/base/mp_jsonout.sas
CHANGED
|
@@ -157,7 +157,12 @@
|
|
|
157
157
|
));
|
|
158
158
|
%do i=1 %to &numcols;
|
|
159
159
|
length &&name&i $&&len&i;
|
|
160
|
-
&&
|
|
160
|
+
%if &&typelong&i=num %then %do;
|
|
161
|
+
&&name&i=left(put(&&newname&i,&&fmt&i));
|
|
162
|
+
%end;
|
|
163
|
+
%else %do;
|
|
164
|
+
&&name&i=put(&&newname&i,&&fmt&i);
|
|
165
|
+
%end;
|
|
161
166
|
drop &&newname&i;
|
|
162
167
|
%end;
|
|
163
168
|
if _error_ then call symputx('syscc',1012);
|
package/base/mp_stackdiffs.sas
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Prepares an audit table for stacking (re-applying) the changes.
|
|
4
|
-
@details
|
|
5
|
-
|
|
6
|
-
When the underlying data from a Base Table is refreshed, it can be helpful
|
|
7
|
-
to have any previously-applied changes, re-applied.
|
|
4
|
+
@details When the underlying data from a Base Table is refreshed, it can be
|
|
5
|
+
helpful to have any previously-applied changes, re-applied.
|
|
8
6
|
|
|
9
7
|
Such situation might arise if you are applying those changes using a tool
|
|
10
8
|
like [Data Controller for SAS®](https://datacontroller.io) - which records
|
|
@@ -23,23 +21,23 @@
|
|
|
23
21
|
|
|
24
22
|
Essentially then, what this macro does, is turn a table like this:
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
|KEY_HASH:$32.|MOVE_TYPE:$1.|TGTVAR_NM:$32.|IS_PK:best.|IS_DIFF:best.|TGTVAR_TYPE:$1.|OLDVAL_NUM:best32.|NEWVAL_NUM:best32.|OLDVAL_CHAR:$32765.|NEWVAL_CHAR:$32765.|
|
|
25
|
+
|---|---|---|---|---|---|---|---|---|---|
|
|
26
|
+
|`27AA6F7581052E7FF48E1BCA901313FB `|`A `|`NAME `|`1 `|`-1 `|`C `|`. `|`. `|` `|`Newbie `|
|
|
27
|
+
|`27AA6F7581052E7FF48E1BCA901313FB `|`A `|`AGE `|`0 `|`-1 `|`N `|`. `|`13 `|` `|` `|
|
|
28
|
+
|`27AA6F7581052E7FF48E1BCA901313FB `|`A `|`HEIGHT `|`0 `|`-1 `|`N `|`. `|`65.3 `|` `|` `|
|
|
29
|
+
|`27AA6F7581052E7FF48E1BCA901313FB `|`A `|`SEX `|`0 `|`-1 `|`C `|`. `|`. `|` `|`F `|
|
|
30
|
+
|`27AA6F7581052E7FF48E1BCA901313FB `|`A `|`WEIGHT `|`0 `|`-1 `|`N `|`. `|`98 `|` `|` `|
|
|
31
|
+
|`86703FDE9E87DD5C0F8E1072545D0128 `|`D `|`NAME `|`1 `|`-1 `|`C `|`. `|`. `|`Alfred `|` `|
|
|
32
|
+
|`86703FDE9E87DD5C0F8E1072545D0128 `|`D `|`AGE `|`0 `|`-1 `|`N `|`14 `|`. `|` `|` `|
|
|
33
|
+
|`86703FDE9E87DD5C0F8E1072545D0128 `|`D `|`HEIGHT `|`0 `|`-1 `|`N `|`69 `|`. `|` `|` `|
|
|
34
|
+
|`86703FDE9E87DD5C0F8E1072545D0128 `|`D `|`SEX `|`0 `|`-1 `|`C `|`. `|`. `|`M `|` `|
|
|
35
|
+
|`86703FDE9E87DD5C0F8E1072545D0128 `|`D `|`WEIGHT `|`0 `|`-1 `|`N `|`112.5 `|`. `|` `|` `|
|
|
36
|
+
|`64489C85DC2FE0787B85CD87214B3810 `|`M `|`NAME `|`1 `|`0 `|`C `|`. `|`. `|`Alice `|`Alice `|
|
|
37
|
+
|`64489C85DC2FE0787B85CD87214B3810 `|`M `|`AGE `|`0 `|`1 `|`N `|`13 `|`99 `|` `|` `|
|
|
38
|
+
|`64489C85DC2FE0787B85CD87214B3810 `|`M `|`HEIGHT `|`0 `|`0 `|`N `|`56.5 `|`56.5 `|` `|` `|
|
|
39
|
+
|`64489C85DC2FE0787B85CD87214B3810 `|`M `|`SEX `|`0 `|`0 `|`C `|`. `|`. `|`F `|`F `|
|
|
40
|
+
|`64489C85DC2FE0787B85CD87214B3810 `|`M `|`WEIGHT `|`0 `|`0 `|`N `|`84 `|`84 `|` `|` `|
|
|
43
41
|
|
|
44
42
|
Into three tables like this:
|
|
45
43
|
|
|
@@ -67,7 +65,7 @@
|
|
|
67
65
|
The macro is also flexible where columns have been added or removed from
|
|
68
66
|
the base table UNLESS there is a change to the primary key.
|
|
69
67
|
|
|
70
|
-
Changes to the primary key are NOT supported, and are likely to cause
|
|
68
|
+
Changes to the primary key fields are NOT supported, and are likely to cause
|
|
71
69
|
unexpected results.
|
|
72
70
|
|
|
73
71
|
The following pre-flight checks are made:
|
|
@@ -184,7 +182,6 @@
|
|
|
184
182
|
@param [out] outadd= (work.outadd) Output table containing additional records
|
|
185
183
|
@param [out] outdel= (work.outdel) Output table containing deleted records
|
|
186
184
|
|
|
187
|
-
|
|
188
185
|
<h4> SAS Macros </h4>
|
|
189
186
|
@li mf_existvarlist.sas
|
|
190
187
|
@li mf_getquotedstr.sas
|
|
@@ -196,7 +193,6 @@
|
|
|
196
193
|
@li mp_abort.sas
|
|
197
194
|
@li mp_ds2squeeze.sas
|
|
198
195
|
|
|
199
|
-
|
|
200
196
|
<h4> Related Macros </h4>
|
|
201
197
|
@li mp_coretable.sas
|
|
202
198
|
@li mp_stackdiffs.test.sas
|
package/base/mp_testservice.sas
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
@file
|
|
3
|
-
@brief Will execute a
|
|
2
|
+
@file
|
|
3
|
+
@brief Will execute a SASjs web service on SAS 9 or Viya
|
|
4
4
|
@details Prepares the input files and retrieves the resulting datasets from
|
|
5
5
|
the response JSON.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
duration=60*5
|
|
9
|
-
)
|
|
7
|
+
|
|
10
8
|
|
|
11
9
|
Note - the _webout fileref should NOT be assigned prior to running this macro.
|
|
12
10
|
|
|
@@ -14,6 +12,10 @@
|
|
|
14
12
|
@param [in] inputfiles=(0) A list of space seperated fileref:filename pairs as
|
|
15
13
|
follows:
|
|
16
14
|
inputfiles=inref:filename inref2:filename2
|
|
15
|
+
@param [in] inputdatasets= (0) All datasets in this space seperated list are
|
|
16
|
+
converted into SASJS-formatted CSVs (see mp_ds2csv.sas) files and added to
|
|
17
|
+
the list of `inputfiles` for ingestion. The dataset will be sent with the
|
|
18
|
+
same name (no need for a colon modifier).
|
|
17
19
|
@param [in] inputparams=(0) A dataset containing name/value pairs in the
|
|
18
20
|
following format:
|
|
19
21
|
|name:$32|value:$1000|
|
|
@@ -38,9 +40,13 @@
|
|
|
38
40
|
@li mf_getuniquename.sas
|
|
39
41
|
@li mp_abort.sas
|
|
40
42
|
@li mp_binarycopy.sas
|
|
43
|
+
@li mp_ds2csv.sas
|
|
41
44
|
@li mv_getjobresult.sas
|
|
42
45
|
@li mv_jobflow.sas
|
|
43
46
|
|
|
47
|
+
<h4> Related Programs </h4>
|
|
48
|
+
@li mp_testservice.test.sas
|
|
49
|
+
|
|
44
50
|
@version 9.4
|
|
45
51
|
@author Allan Bowe
|
|
46
52
|
|
|
@@ -48,6 +54,7 @@
|
|
|
48
54
|
|
|
49
55
|
%macro mp_testservice(program,
|
|
50
56
|
inputfiles=0,
|
|
57
|
+
inputdatasets=0,
|
|
51
58
|
inputparams=0,
|
|
52
59
|
debug=log,
|
|
53
60
|
mdebug=0,
|
|
@@ -56,7 +63,7 @@
|
|
|
56
63
|
viyaresult=WEBOUT_JSON,
|
|
57
64
|
viyacontext=SAS Job Execution compute context
|
|
58
65
|
)/*/STORE SOURCE*/;
|
|
59
|
-
%local dbg;
|
|
66
|
+
%local dbg pcnt fref1 webref i webcount var platform;
|
|
60
67
|
%if &mdebug=1 %then %do;
|
|
61
68
|
%put &sysmacroname entry vars:;
|
|
62
69
|
%put _local_;
|
|
@@ -64,7 +71,6 @@
|
|
|
64
71
|
%else %let dbg=*;
|
|
65
72
|
|
|
66
73
|
/* sanitise inputparams */
|
|
67
|
-
%local pcnt;
|
|
68
74
|
%let pcnt=0;
|
|
69
75
|
%if &inputparams ne 0 %then %do;
|
|
70
76
|
data _null_;
|
|
@@ -86,17 +92,25 @@
|
|
|
86
92
|
)
|
|
87
93
|
%end;
|
|
88
94
|
|
|
95
|
+
/* convert inputdatasets to filerefs */
|
|
96
|
+
%if "&inputdatasets" ne "0" %then %do;
|
|
97
|
+
%if %quote(&inputfiles)=0 %then %let inputfiles=;
|
|
98
|
+
%do i=1 %to %sysfunc(countw(&inputdatasets,%str( )));
|
|
99
|
+
%let var=%scan(&inputdatasets,&i,%str( ));
|
|
100
|
+
%local dsref&i;
|
|
101
|
+
%let dsref&i=%mf_getuniquefileref();
|
|
102
|
+
%mp_ds2csv(&var,outref=&&dsref&i,headerformat=SASJS)
|
|
103
|
+
%let inputfiles=&inputfiles &&dsref&i:%scan(&var,-1,.);
|
|
104
|
+
%end;
|
|
105
|
+
%end;
|
|
106
|
+
|
|
89
107
|
|
|
90
|
-
%local fref1 webref;
|
|
91
108
|
%let fref1=%mf_getuniquefileref();
|
|
92
109
|
%let webref=%mf_getuniquefileref();
|
|
93
|
-
|
|
94
|
-
%local platform;
|
|
95
110
|
%let platform=%mf_getplatform();
|
|
96
111
|
%if &platform=SASMETA %then %do;
|
|
97
112
|
|
|
98
113
|
/* parse the input files */
|
|
99
|
-
%local webcount i var;
|
|
100
114
|
%if %quote(&inputfiles) ne 0 %then %do;
|
|
101
115
|
%let webcount=%sysfunc(countw(&inputfiles));
|
|
102
116
|
%put &=webcount;
|
package/meta/mm_createstp.sas
CHANGED
|
@@ -190,7 +190,12 @@ data _null_;
|
|
|
190
190
|
put ' )); ';
|
|
191
191
|
put ' %do i=1 %to &numcols; ';
|
|
192
192
|
put ' length &&name&i $&&len&i; ';
|
|
193
|
-
put ' &&
|
|
193
|
+
put ' %if &&typelong&i=num %then %do; ';
|
|
194
|
+
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
|
195
|
+
put ' %end; ';
|
|
196
|
+
put ' %else %do; ';
|
|
197
|
+
put ' &&name&i=put(&&newname&i,&&fmt&i); ';
|
|
198
|
+
put ' %end; ';
|
|
194
199
|
put ' drop &&newname&i; ';
|
|
195
200
|
put ' %end; ';
|
|
196
201
|
put ' if _error_ then call symputx(''syscc'',1012); ';
|
|
@@ -41,7 +41,11 @@ run;
|
|
|
41
41
|
|
|
42
42
|
filename __mc1 temp;
|
|
43
43
|
filename __mc2 temp;
|
|
44
|
-
data &outds;
|
|
44
|
+
data &outds;
|
|
45
|
+
length serveruri servername $200;
|
|
46
|
+
call missing (of _all_);
|
|
47
|
+
stop;
|
|
48
|
+
run;
|
|
45
49
|
%do x=1 %to &repocnt;
|
|
46
50
|
options metarepository=&&repo&x;
|
|
47
51
|
proc metadata in=
|
|
@@ -60,13 +64,16 @@ data &outds; length serveruri servername $200; stop;run;
|
|
|
60
64
|
data _null_;
|
|
61
65
|
file __mc2;
|
|
62
66
|
put '<SXLEMAP version="1.2" name="SASContexts"><TABLE name="SASContexts">';
|
|
63
|
-
put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext
|
|
67
|
+
put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext";
|
|
68
|
+
put "</TABLE-PATH>";
|
|
64
69
|
put '<COLUMN name="serveruri">';
|
|
65
|
-
put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Id
|
|
70
|
+
put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Id";
|
|
71
|
+
put "</PATH>";
|
|
66
72
|
put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
|
|
67
73
|
put '</COLUMN>';
|
|
68
74
|
put '<COLUMN name="servername">';
|
|
69
|
-
put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Name
|
|
75
|
+
put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Name";
|
|
76
|
+
put "</PATH>";
|
|
70
77
|
put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
|
|
71
78
|
put '</COLUMN>';
|
|
72
79
|
put '</TABLE></SXLEMAP>';
|
package/package.json
CHANGED
|
@@ -334,7 +334,12 @@ data _null_;
|
|
|
334
334
|
put ' )); ';
|
|
335
335
|
put ' %do i=1 %to &numcols; ';
|
|
336
336
|
put ' length &&name&i $&&len&i; ';
|
|
337
|
-
put ' &&
|
|
337
|
+
put ' %if &&typelong&i=num %then %do; ';
|
|
338
|
+
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
|
339
|
+
put ' %end; ';
|
|
340
|
+
put ' %else %do; ';
|
|
341
|
+
put ' &&name&i=put(&&newname&i,&&fmt&i); ';
|
|
342
|
+
put ' %end; ';
|
|
338
343
|
put ' drop &&newname&i; ';
|
|
339
344
|
put ' %end; ';
|
|
340
345
|
put ' if _error_ then call symputx(''syscc'',1012); ';
|