@sasjs/core 4.19.0 → 4.21.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_getuniquefileref.sas +5 -3
- package/base/mf_isint.sas +4 -1
- package/base/mp_chop.sas +194 -0
- package/base/mp_createwebservice.sas +13 -2
- package/base/mp_gsubfile.sas +1 -1
- package/base/mp_jsonout.sas +1 -1
- package/base/mp_replace.sas +4 -2
- package/base/mp_streamfile.sas +29 -21
- package/base/mp_testservice.sas +27 -4
- package/lua/ml_gsubfile.sas +8 -0
- package/lua/ml_json.sas +8 -0
- package/meta/mm_createwebservice.sas +20 -20
- package/package.json +1 -1
- package/server/mfs_httpheader.sas +2 -1
- package/server/ms_createfile.sas +8 -4
- package/server/ms_createwebservice.sas +532 -0
- package/server/ms_runstp.sas +128 -7
- package/server/ms_testservice.sas +152 -0
- package/server/ms_webout.sas +9 -8
- package/viya/mv_createwebservice.sas +20 -20
|
@@ -28,15 +28,17 @@
|
|
|
28
28
|
be 8 characters, so a 7 letter prefix would mean `maxtries` should be 10.
|
|
29
29
|
if using zero (0) as the prefix, a native assignment is used.
|
|
30
30
|
@param [in] maxtries= (1000) the last part of the libref. Must be an integer.
|
|
31
|
+
@param [in] lrecl= (32767) Provide a default lrecl with which to initialise
|
|
32
|
+
the generated fileref.
|
|
31
33
|
|
|
32
34
|
@version 9.2
|
|
33
35
|
@author Allan Bowe
|
|
34
36
|
**/
|
|
35
37
|
|
|
36
|
-
%macro mf_getuniquefileref(prefix=_,maxtries=1000);
|
|
38
|
+
%macro mf_getuniquefileref(prefix=_,maxtries=1000,lrecl=32767);
|
|
37
39
|
%local rc fname;
|
|
38
40
|
%if &prefix=0 %then %do;
|
|
39
|
-
%let rc=%sysfunc(filename(fname,,temp));
|
|
41
|
+
%let rc=%sysfunc(filename(fname,,temp,lrecl=&lrecl));
|
|
40
42
|
%if &rc %then %put %sysfunc(sysmsg());
|
|
41
43
|
&fname
|
|
42
44
|
%end;
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
%do x=0 %to &maxtries;
|
|
48
50
|
%let fname=&prefix%substr(%sysfunc(ranuni(0)),3,&len);
|
|
49
51
|
%if %sysfunc(fileref(&fname)) > 0 %then %do;
|
|
50
|
-
%let rc=%sysfunc(filename(fname,,temp));
|
|
52
|
+
%let rc=%sysfunc(filename(fname,,temp,lrecl=&lrecl));
|
|
51
53
|
%if &rc %then %put %sysfunc(sysmsg());
|
|
52
54
|
&fname
|
|
53
55
|
%return;
|
package/base/mf_isint.sas
CHANGED
|
@@ -20,8 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
%macro mf_isint(arg
|
|
22
22
|
)/*/STORE SOURCE*/;
|
|
23
|
-
/* remove minus sign if exists */
|
|
24
23
|
|
|
24
|
+
/* blank val is not an integer */
|
|
25
|
+
%if "&arg"="" %then %do;0%return;%end;
|
|
26
|
+
|
|
27
|
+
/* remove minus sign if exists */
|
|
25
28
|
%local val;
|
|
26
29
|
%if "%substr(%str(&arg),1,1)"="-" %then %let val=%substr(%str(&arg),2);
|
|
27
30
|
%else %let val=&arg;
|
package/base/mp_chop.sas
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Splits a file of ANY SIZE by reference to a search string.
|
|
4
|
+
@details Provide a fileref and a search string to chop off part of a file.
|
|
5
|
+
|
|
6
|
+
Works by reading in the file byte by byte, then marking the beginning and end
|
|
7
|
+
of each matched string, before finally doing the chop.
|
|
8
|
+
|
|
9
|
+
Choose whether to keep the FIRST or the LAST section of the file. Optionally,
|
|
10
|
+
use an OFFSET to fix the precise chop point.
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
|
|
14
|
+
%let src="%sysfunc(pathname(work))/file.txt";
|
|
15
|
+
%let str=Chop here!;
|
|
16
|
+
%let out1="%sysfunc(pathname(work))/file1.txt";
|
|
17
|
+
%let out2="%sysfunc(pathname(work))/file2.txt";
|
|
18
|
+
%let out3="%sysfunc(pathname(work))/file3.txt";
|
|
19
|
+
%let out4="%sysfunc(pathname(work))/file4.txt";
|
|
20
|
+
|
|
21
|
+
data _null_;
|
|
22
|
+
file &src;
|
|
23
|
+
put "startsection&str.endsection";
|
|
24
|
+
run;
|
|
25
|
+
|
|
26
|
+
%mp_chop(&src, matchvar=str, keep=FIRST, outfile=&out1)
|
|
27
|
+
%mp_chop(&src, matchvar=str, keep=LAST, outfile=&out2)
|
|
28
|
+
%mp_chop(&src, matchvar=str, keep=FIRST, matchpoint=END, outfile=&out3)
|
|
29
|
+
%mp_chop(&src, matchvar=str, keep=LAST, matchpoint=END, outfile=&out4)
|
|
30
|
+
|
|
31
|
+
filename results (&out1 &out2 &out3 &out4);
|
|
32
|
+
data _null_;
|
|
33
|
+
infile results;
|
|
34
|
+
input;
|
|
35
|
+
list;
|
|
36
|
+
run;
|
|
37
|
+
|
|
38
|
+
Results:
|
|
39
|
+
@li `startsection`
|
|
40
|
+
@li `Chop here!endsection`
|
|
41
|
+
@li `startsectionChop here!`
|
|
42
|
+
@li `endsection`
|
|
43
|
+
|
|
44
|
+
For more examples, see mp_chop.test.sas
|
|
45
|
+
|
|
46
|
+
@param [in] infile The QUOTED path to the file on which to perform the chop
|
|
47
|
+
@param [in] matchvar= Macro variable NAME containing the string to split by
|
|
48
|
+
@param [in] matchpoint= (START) Valid values:
|
|
49
|
+
@li START - chop at the beginning of the string in `matchvar`.
|
|
50
|
+
@li END - chop at the end of the string in `matchvar`.
|
|
51
|
+
@param [in] offset= (0) An adjustment to the precise chop location, by
|
|
52
|
+
by reference to the `matchpoint`. Should be a positive or negative integer.
|
|
53
|
+
@param [in] keep= (FIRST) Valid values:
|
|
54
|
+
@li FIRST - keep the section of the file before the chop
|
|
55
|
+
@li LAST - keep the section of the file after the chop
|
|
56
|
+
@param [in] mdebug= (0) Set to 1 to provide macro debugging
|
|
57
|
+
@param outfile= (0) Optional QUOTED path to the adjusted output file (avoids
|
|
58
|
+
overwriting the first file).
|
|
59
|
+
|
|
60
|
+
<h4> SAS Macros </h4>
|
|
61
|
+
@li mf_getuniquefileref.sas
|
|
62
|
+
@li mf_getuniquename.sas
|
|
63
|
+
|
|
64
|
+
<h4> Related Macros </h4>
|
|
65
|
+
@li mp_abort.sas
|
|
66
|
+
@li mp_gsubfile.sas
|
|
67
|
+
@li mp_replace.sas
|
|
68
|
+
@li mp_chop.test.sas
|
|
69
|
+
|
|
70
|
+
@version 9.4
|
|
71
|
+
@author Allan Bowe
|
|
72
|
+
|
|
73
|
+
**/
|
|
74
|
+
|
|
75
|
+
%macro mp_chop(infile,
|
|
76
|
+
matchvar=,
|
|
77
|
+
matchpoint=START,
|
|
78
|
+
keep=FIRST,
|
|
79
|
+
offset=0,
|
|
80
|
+
mdebug=0,
|
|
81
|
+
outfile=0
|
|
82
|
+
)/*/STORE SOURCE*/;
|
|
83
|
+
|
|
84
|
+
%local fref0 dttm ds1 outref;
|
|
85
|
+
%let fref0=%mf_getuniquefileref();
|
|
86
|
+
%let ds1=%mf_getuniquename(prefix=allchars);
|
|
87
|
+
%let ds2=%mf_getuniquename(prefix=startmark);
|
|
88
|
+
|
|
89
|
+
%if &outfile=0 %then %let outfile=&infile;
|
|
90
|
+
|
|
91
|
+
%mp_abort(iftrue= (%length(%superq(&matchvar))=0)
|
|
92
|
+
,mac=mp_chop.sas
|
|
93
|
+
,msg=%str(&matchvar is an empty variable)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
/* START */
|
|
97
|
+
%let dttm=%sysfunc(datetime());
|
|
98
|
+
|
|
99
|
+
filename &fref0 &infile lrecl=1 recfm=n;
|
|
100
|
+
|
|
101
|
+
/* create dataset with one char per row */
|
|
102
|
+
data &ds1;
|
|
103
|
+
infile &fref0;
|
|
104
|
+
input sourcechar $char1. @@;
|
|
105
|
+
format sourcechar hex2.;
|
|
106
|
+
run;
|
|
107
|
+
|
|
108
|
+
/* get start & stop position of first matchvar string (one row, two vars) */
|
|
109
|
+
data &ds2;
|
|
110
|
+
/* set find string to length in bytes to cover trailing spaces */
|
|
111
|
+
length string $ %length(%superq(&matchvar));
|
|
112
|
+
string =symget("&matchvar");
|
|
113
|
+
drop string;
|
|
114
|
+
|
|
115
|
+
firstchar=char(string,1);
|
|
116
|
+
findlen=lengthm(string); /* <- for trailing bytes */
|
|
117
|
+
|
|
118
|
+
do _N_=1 to nobs;
|
|
119
|
+
set &ds1 nobs=nobs point=_N_;
|
|
120
|
+
if sourcechar=firstchar then do;
|
|
121
|
+
pos=1;
|
|
122
|
+
s=0;
|
|
123
|
+
do point=_N_ to min(_N_ + findlen -1,nobs);
|
|
124
|
+
set &ds1 point=point;
|
|
125
|
+
if sourcechar=char(string, pos) then s + 1;
|
|
126
|
+
else goto _leave_;
|
|
127
|
+
pos+1;
|
|
128
|
+
end;
|
|
129
|
+
_leave_:
|
|
130
|
+
if s=findlen then do;
|
|
131
|
+
START =_N_;
|
|
132
|
+
_N_ =_N_+ s - 1;
|
|
133
|
+
STOP =_N_;
|
|
134
|
+
output;
|
|
135
|
+
/* matched! */
|
|
136
|
+
stop;
|
|
137
|
+
end;
|
|
138
|
+
end;
|
|
139
|
+
end;
|
|
140
|
+
stop;
|
|
141
|
+
keep START STOP;
|
|
142
|
+
run;
|
|
143
|
+
|
|
144
|
+
%local split;
|
|
145
|
+
%let split=0;
|
|
146
|
+
data _null_;
|
|
147
|
+
set &ds2;
|
|
148
|
+
if "&matchpoint"='START' then do;
|
|
149
|
+
if "&keep"='FIRST' then mp=start;
|
|
150
|
+
else if "&keep"='LAST' then mp=start-1;
|
|
151
|
+
end;
|
|
152
|
+
else if "&matchpoint"='END' then do;
|
|
153
|
+
if "&keep"='FIRST' then mp=stop+1;
|
|
154
|
+
else if "&keep"='LAST' then mp=stop;
|
|
155
|
+
end;
|
|
156
|
+
split=mp+&offset;
|
|
157
|
+
call symputx('split',split,'l');
|
|
158
|
+
%if &mdebug=1 %then %do;
|
|
159
|
+
put (_all_)(=);
|
|
160
|
+
%put &=offset;
|
|
161
|
+
%end;
|
|
162
|
+
run;
|
|
163
|
+
%if &split=0 %then %do;
|
|
164
|
+
%put &sysmacroname: No match found in &infile for string %superq(&matchvar);
|
|
165
|
+
%return;
|
|
166
|
+
%end;
|
|
167
|
+
|
|
168
|
+
data _null_;
|
|
169
|
+
file &outfile recfm=n;
|
|
170
|
+
set &ds1;
|
|
171
|
+
%if &keep=FIRST %then %do;
|
|
172
|
+
if _n_ ge &split then stop;
|
|
173
|
+
%end;
|
|
174
|
+
%else %do;
|
|
175
|
+
if _n_ gt &split;
|
|
176
|
+
%end;
|
|
177
|
+
put sourcechar char1.;
|
|
178
|
+
run;
|
|
179
|
+
|
|
180
|
+
%if &mdebug=0 %then %do;
|
|
181
|
+
filename &fref0 clear;
|
|
182
|
+
%end;
|
|
183
|
+
%else %do;
|
|
184
|
+
data _null_;
|
|
185
|
+
infile &outfile lrecl=32767;
|
|
186
|
+
input;
|
|
187
|
+
list;
|
|
188
|
+
if _n_>50 then stop;
|
|
189
|
+
run;
|
|
190
|
+
%end;
|
|
191
|
+
/* END */
|
|
192
|
+
%put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) seconds to run;
|
|
193
|
+
|
|
194
|
+
%mend mp_chop;
|
|
@@ -29,6 +29,7 @@ Usage:
|
|
|
29
29
|
<h4> SAS Macros </h4>
|
|
30
30
|
@li mf_getplatform.sas
|
|
31
31
|
@li mm_createwebservice.sas
|
|
32
|
+
@li ms_createwebservice.sas
|
|
32
33
|
@li mv_createwebservice.sas
|
|
33
34
|
|
|
34
35
|
@param [in,out] path= The full folder path where the service will be created
|
|
@@ -40,7 +41,7 @@ Usage:
|
|
|
40
41
|
be added
|
|
41
42
|
@param [in] replace= (YES) Select YES to replace any existing service in that
|
|
42
43
|
location
|
|
43
|
-
|
|
44
|
+
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
|
44
45
|
|
|
45
46
|
@version 9.2
|
|
46
47
|
@author Allan Bowe
|
|
@@ -53,6 +54,7 @@ Usage:
|
|
|
53
54
|
,code=ft15f001
|
|
54
55
|
,desc=This service was created by the mp_createwebservice macro
|
|
55
56
|
,replace=YES
|
|
57
|
+
,mdebug=0
|
|
56
58
|
)/*/STORE SOURCE*/;
|
|
57
59
|
|
|
58
60
|
%if &syscc ge 4 %then %do;
|
|
@@ -71,8 +73,17 @@ Usage:
|
|
|
71
73
|
,replace=&replace
|
|
72
74
|
)
|
|
73
75
|
%end;
|
|
76
|
+
%else %if &platform=SASJS %then %do;
|
|
77
|
+
%if "&path"="HOME" %then %let path=/Users/&_sasjs_username/My Folder;
|
|
78
|
+
%ms_createwebservice(path=&path
|
|
79
|
+
,name=&name
|
|
80
|
+
,code=&code
|
|
81
|
+
,precode=&precode
|
|
82
|
+
,mdebug=&mdebug
|
|
83
|
+
)
|
|
84
|
+
%end;
|
|
74
85
|
%else %do;
|
|
75
|
-
%if "&path"="HOME" %then %let path=/User Folders/&
|
|
86
|
+
%if "&path"="HOME" %then %let path=/User Folders/&_METAPERSON/My Folder;
|
|
76
87
|
%mm_createwebservice(path=&path
|
|
77
88
|
,name=&name
|
|
78
89
|
,code=&code
|
package/base/mp_gsubfile.sas
CHANGED
package/base/mp_jsonout.sas
CHANGED
package/base/mp_replace.sas
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
@param infile The QUOTED path to the file on which to perform the substitution
|
|
36
36
|
@param findvar= Macro variable NAME containing the string to search for
|
|
37
37
|
@param replacevar= Macro variable NAME containing the replacement string
|
|
38
|
-
@param outfile= (0) Optional QUOTED path to
|
|
38
|
+
@param outfile= (0) Optional QUOTED path to the adjusted output file (to
|
|
39
39
|
avoid overwriting the first file).
|
|
40
40
|
|
|
41
41
|
<h4> SAS Macros </h4>
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
@li mf_getuniquename.sas
|
|
44
44
|
|
|
45
45
|
<h4> Related Macros </h4>
|
|
46
|
-
@li
|
|
46
|
+
@li mp_chop.sas
|
|
47
|
+
@li mp_gsubfile.sas
|
|
48
|
+
@li mp_replace.test.sas
|
|
47
49
|
|
|
48
50
|
@version 9.4
|
|
49
51
|
@author Bartosz Jabłoński
|
package/base/mp_streamfile.sas
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Streams a file to _webout according to content type
|
|
4
|
-
@details Will set headers using appropriate functions
|
|
5
|
-
|
|
4
|
+
@details Will set headers using appropriate functions per the server type
|
|
5
|
+
(Viya, EBI, [SASjs Server](https://github.com/sasjs/server)) and stream
|
|
6
|
+
content using mp_binarycopy().
|
|
6
7
|
|
|
7
8
|
Usage:
|
|
8
9
|
|
|
@@ -12,7 +13,14 @@
|
|
|
12
13
|
|
|
13
14
|
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
|
14
15
|
|
|
15
|
-
@param [in] contenttype= (TEXT)
|
|
16
|
+
@param [in] contenttype= (TEXT) Supported:
|
|
17
|
+
@li CSV
|
|
18
|
+
@li EXCEL
|
|
19
|
+
@li MARKDOWN
|
|
20
|
+
@li TEXT
|
|
21
|
+
@li ZIP
|
|
22
|
+
Feel free to submit PRs to support more mime types! The official list is
|
|
23
|
+
here: https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
16
24
|
@param [in] inloc= /path/to/file.ext to be sent
|
|
17
25
|
@param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
18
26
|
@param [in] iftrue= (1=1) Provide a condition under which to execute.
|
|
@@ -58,7 +66,7 @@ run;
|
|
|
58
66
|
%if &contentype=CSV %then %do;
|
|
59
67
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
60
68
|
data _null_;
|
|
61
|
-
rc=stpsrv_header('Content-
|
|
69
|
+
rc=stpsrv_header('Content-Type','application/csv');
|
|
62
70
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
63
71
|
run;
|
|
64
72
|
%end;
|
|
@@ -68,7 +76,7 @@ run;
|
|
|
68
76
|
contentdisp="attachment; filename=&outname";
|
|
69
77
|
%end;
|
|
70
78
|
%else %if &platform=SASJS %then %do;
|
|
71
|
-
%mfs_httpheader(Content-
|
|
79
|
+
%mfs_httpheader(Content-Type,application/csv)
|
|
72
80
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
73
81
|
%end;
|
|
74
82
|
%end;
|
|
@@ -76,7 +84,7 @@ run;
|
|
|
76
84
|
/* suitable for XLS format */
|
|
77
85
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
78
86
|
data _null_;
|
|
79
|
-
rc=stpsrv_header('Content-
|
|
87
|
+
rc=stpsrv_header('Content-Type','application/vnd.ms-excel');
|
|
80
88
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
81
89
|
run;
|
|
82
90
|
%end;
|
|
@@ -86,14 +94,14 @@ run;
|
|
|
86
94
|
contentdisp="attachment; filename=&outname";
|
|
87
95
|
%end;
|
|
88
96
|
%else %if &platform=SASJS %then %do;
|
|
89
|
-
%mfs_httpheader(Content-
|
|
97
|
+
%mfs_httpheader(Content-Type,application/vnd.ms-excel)
|
|
90
98
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
91
99
|
%end;
|
|
92
100
|
%end;
|
|
93
101
|
%else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
|
|
94
102
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
95
103
|
data _null_;
|
|
96
|
-
rc=stpsrv_header('Content-
|
|
104
|
+
rc=stpsrv_header('Content-Type',"image/%lowcase(&contenttype)");
|
|
97
105
|
run;
|
|
98
106
|
%end;
|
|
99
107
|
%else %if &platform=SASVIYA %then %do;
|
|
@@ -101,30 +109,30 @@ run;
|
|
|
101
109
|
contenttype="image/%lowcase(&contenttype)";
|
|
102
110
|
%end;
|
|
103
111
|
%else %if &platform=SASJS %then %do;
|
|
104
|
-
%mfs_httpheader(Content-
|
|
112
|
+
%mfs_httpheader(Content-Type,image/%lowcase(&contenttype))
|
|
105
113
|
%end;
|
|
106
114
|
%end;
|
|
107
|
-
%else %if &contentype=HTML %then %do;
|
|
115
|
+
%else %if &contentype=HTML or &contenttype=MARKDOWN %then %do;
|
|
108
116
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
109
117
|
data _null_;
|
|
110
|
-
rc=stpsrv_header('Content-
|
|
118
|
+
rc=stpsrv_header('Content-Type',"text/%lowcase(&contenttype)");
|
|
111
119
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
112
120
|
run;
|
|
113
121
|
%end;
|
|
114
122
|
%else %if &platform=SASVIYA %then %do;
|
|
115
123
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
116
|
-
contenttype="text
|
|
124
|
+
contenttype="text/%lowcase(&contenttype)"
|
|
117
125
|
contentdisp="attachment; filename=&outname";
|
|
118
126
|
%end;
|
|
119
127
|
%else %if &platform=SASJS %then %do;
|
|
120
|
-
%mfs_httpheader(Content-
|
|
128
|
+
%mfs_httpheader(Content-Type,text/%lowcase(&contenttype))
|
|
121
129
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
122
130
|
%end;
|
|
123
131
|
%end;
|
|
124
132
|
%else %if &contentype=TEXT %then %do;
|
|
125
133
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
126
134
|
data _null_;
|
|
127
|
-
rc=stpsrv_header('Content-
|
|
135
|
+
rc=stpsrv_header('Content-Type','application/text');
|
|
128
136
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
129
137
|
run;
|
|
130
138
|
%end;
|
|
@@ -134,14 +142,14 @@ run;
|
|
|
134
142
|
contentdisp="attachment; filename=&outname";
|
|
135
143
|
%end;
|
|
136
144
|
%else %if &platform=SASJS %then %do;
|
|
137
|
-
%mfs_httpheader(Content-
|
|
145
|
+
%mfs_httpheader(Content-Type,application/text)
|
|
138
146
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
139
147
|
%end;
|
|
140
148
|
%end;
|
|
141
149
|
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
|
142
150
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
143
151
|
data _null_;
|
|
144
|
-
rc=stpsrv_header('Content-
|
|
152
|
+
rc=stpsrv_header('Content-Type',"font/%lowcase(&contenttype)");
|
|
145
153
|
run;
|
|
146
154
|
%end;
|
|
147
155
|
%else %if &platform=SASVIYA %then %do;
|
|
@@ -149,13 +157,13 @@ run;
|
|
|
149
157
|
contenttype="font/%lowcase(&contenttype)";
|
|
150
158
|
%end;
|
|
151
159
|
%else %if &platform=SASJS %then %do;
|
|
152
|
-
%mfs_httpheader(Content-
|
|
160
|
+
%mfs_httpheader(Content-Type,font/%lowcase(&contenttype))
|
|
153
161
|
%end;
|
|
154
162
|
%end;
|
|
155
163
|
%else %if &contentype=XLSX %then %do;
|
|
156
164
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
157
165
|
data _null_;
|
|
158
|
-
rc=stpsrv_header('Content-
|
|
166
|
+
rc=stpsrv_header('Content-Type',
|
|
159
167
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
160
168
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
161
169
|
run;
|
|
@@ -167,7 +175,7 @@ run;
|
|
|
167
175
|
contentdisp="attachment; filename=&outname";
|
|
168
176
|
%end;
|
|
169
177
|
%else %if &platform=SASJS %then %do;
|
|
170
|
-
%mfs_httpheader(Content-
|
|
178
|
+
%mfs_httpheader(Content-Type
|
|
171
179
|
,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
|
172
180
|
)
|
|
173
181
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
@@ -176,7 +184,7 @@ run;
|
|
|
176
184
|
%else %if &contentype=ZIP %then %do;
|
|
177
185
|
%if (&platform=SASMETA and &streamweb=1) %then %do;
|
|
178
186
|
data _null_;
|
|
179
|
-
rc=stpsrv_header('Content-
|
|
187
|
+
rc=stpsrv_header('Content-Type','application/zip');
|
|
180
188
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
181
189
|
run;
|
|
182
190
|
%end;
|
|
@@ -186,7 +194,7 @@ run;
|
|
|
186
194
|
contentdisp="attachment; filename=&outname";
|
|
187
195
|
%end;
|
|
188
196
|
%else %if &platform=SASJS %then %do;
|
|
189
|
-
%mfs_httpheader(Content-
|
|
197
|
+
%mfs_httpheader(Content-Type,application/zip)
|
|
190
198
|
%mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
|
|
191
199
|
%end;
|
|
192
200
|
%end;
|
package/base/mp_testservice.sas
CHANGED
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
@li mf_getuniquename.sas
|
|
41
41
|
@li mp_abort.sas
|
|
42
42
|
@li mp_binarycopy.sas
|
|
43
|
+
@li mp_chop.sas
|
|
43
44
|
@li mp_ds2csv.sas
|
|
45
|
+
@li ms_testservice.sas
|
|
44
46
|
@li mv_getjobresult.sas
|
|
45
47
|
@li mv_jobflow.sas
|
|
46
48
|
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
viyaresult=WEBOUT_JSON,
|
|
64
66
|
viyacontext=SAS Job Execution compute context
|
|
65
67
|
)/*/STORE SOURCE*/;
|
|
66
|
-
%local dbg pcnt fref1 webref i webcount var platform;
|
|
68
|
+
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform;
|
|
67
69
|
%if &mdebug=1 %then %do;
|
|
68
70
|
%put &sysmacroname entry vars:;
|
|
69
71
|
%put _local_;
|
|
@@ -104,10 +106,14 @@
|
|
|
104
106
|
%end;
|
|
105
107
|
%end;
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
%let platform=%mf_getplatform();
|
|
108
110
|
%let fref1=%mf_getuniquefileref();
|
|
111
|
+
%let fref2=%mf_getuniquefileref();
|
|
109
112
|
%let webref=%mf_getuniquefileref();
|
|
110
|
-
%let
|
|
113
|
+
%let webrefpath=%sysfunc(pathname(work))/%mf_getuniquename();
|
|
114
|
+
/* mp_chop requires a physical path as input */
|
|
115
|
+
filename &webref "&webrefpath";
|
|
116
|
+
|
|
111
117
|
%if &platform=SASMETA %then %do;
|
|
112
118
|
|
|
113
119
|
/* parse the input files */
|
|
@@ -262,13 +268,30 @@
|
|
|
262
268
|
mdebug=&mdebug
|
|
263
269
|
)
|
|
264
270
|
|
|
271
|
+
%end;
|
|
272
|
+
%else %if &platform=SASJS %then %do;
|
|
273
|
+
|
|
274
|
+
%ms_testservice(&program
|
|
275
|
+
,inputfiles=&inputfiles
|
|
276
|
+
,inputdatasets=&inputdatasets
|
|
277
|
+
,inputparams=&inputparams
|
|
278
|
+
,debug=&debug
|
|
279
|
+
,mdebug=&mdebug
|
|
280
|
+
,outlib=&outlib
|
|
281
|
+
,outref=&outref
|
|
282
|
+
)
|
|
283
|
+
|
|
265
284
|
%end;
|
|
266
285
|
%else %do;
|
|
267
286
|
%put %str(ERR)OR: Unrecognised platform: &platform;
|
|
268
287
|
%end;
|
|
269
288
|
|
|
270
289
|
%if &mdebug=0 %then %do;
|
|
271
|
-
filename &
|
|
290
|
+
filename &fref1 clear;
|
|
291
|
+
%if &platform ne SASJS %then %do;
|
|
292
|
+
filename &fref2 clear;
|
|
293
|
+
filename &webref clear;
|
|
294
|
+
%end;
|
|
272
295
|
%end;
|
|
273
296
|
%else %do;
|
|
274
297
|
%put &sysmacroname exit vars:;
|
package/lua/ml_gsubfile.sas
CHANGED
|
@@ -39,6 +39,14 @@ data _null_;
|
|
|
39
39
|
put 'io.close(file) ';
|
|
40
40
|
run;
|
|
41
41
|
|
|
42
|
+
/* ensure big enough lrecl to avoid lua compilation issues */
|
|
43
|
+
%local optval;
|
|
44
|
+
%let optval=%sysfunc(getoption(lrecl));
|
|
45
|
+
options lrecl=1024;
|
|
46
|
+
|
|
47
|
+
/* execute the lua code by using a .lua extension */
|
|
42
48
|
%inc "%sysfunc(pathname(work))/ml_gsubfile.lua" /source2;
|
|
43
49
|
|
|
50
|
+
options lrecl=&optval;
|
|
51
|
+
|
|
44
52
|
%mend ml_gsubfile;
|
package/lua/ml_json.sas
CHANGED
|
@@ -389,6 +389,14 @@ data _null_;
|
|
|
389
389
|
put '-- JSON.LUA ENDS HERE ';
|
|
390
390
|
run;
|
|
391
391
|
|
|
392
|
+
/* ensure big enough lrecl to avoid lua compilation issues */
|
|
393
|
+
%local optval;
|
|
394
|
+
%let optval=%sysfunc(getoption(lrecl));
|
|
395
|
+
options lrecl=1024;
|
|
396
|
+
|
|
397
|
+
/* execute the lua code by using a .lua extension */
|
|
392
398
|
%inc "%sysfunc(pathname(work))/ml_json.lua" /source2;
|
|
393
399
|
|
|
400
|
+
options lrecl=&optval;
|
|
401
|
+
|
|
394
402
|
%mend ml_json;
|
|
@@ -103,7 +103,7 @@ data _null_;
|
|
|
103
103
|
put ' ';
|
|
104
104
|
put '%if &action=OPEN %then %do; ';
|
|
105
105
|
put ' options nobomfile; ';
|
|
106
|
-
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
106
|
+
put ' data _null_;file &jref encoding=''utf-8'' lrecl=200; ';
|
|
107
107
|
put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
|
|
108
108
|
put ' run; ';
|
|
109
109
|
put '%end; ';
|
|
@@ -314,6 +314,25 @@ data _null_;
|
|
|
314
314
|
put ' run; ';
|
|
315
315
|
put '%end; ';
|
|
316
316
|
put '%mend mp_jsonout; ';
|
|
317
|
+
put ' ';
|
|
318
|
+
put '%macro mf_getuser(type=META ';
|
|
319
|
+
put ')/*/STORE SOURCE*/; ';
|
|
320
|
+
put ' %local user metavar; ';
|
|
321
|
+
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
322
|
+
put ' %else %let metavar=_metaperson; ';
|
|
323
|
+
put ' ';
|
|
324
|
+
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
|
325
|
+
put ' %else %if %symexist(&metavar) %then %do; ';
|
|
326
|
+
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
|
327
|
+
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
|
328
|
+
put ' /* but be sure to quote in case of usernames with commas */ ';
|
|
329
|
+
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
|
330
|
+
put ' %end; ';
|
|
331
|
+
put ' %else %let user=&sysuserid; ';
|
|
332
|
+
put ' ';
|
|
333
|
+
put ' %quote(&user) ';
|
|
334
|
+
put ' ';
|
|
335
|
+
put '%mend mf_getuser; ';
|
|
317
336
|
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
|
|
318
337
|
put ' ,showmeta=NO ';
|
|
319
338
|
put '); ';
|
|
@@ -455,25 +474,6 @@ data _null_;
|
|
|
455
474
|
put '%end; ';
|
|
456
475
|
put ' ';
|
|
457
476
|
put '%mend mm_webout; ';
|
|
458
|
-
put ' ';
|
|
459
|
-
put '%macro mf_getuser(type=META ';
|
|
460
|
-
put ')/*/STORE SOURCE*/; ';
|
|
461
|
-
put ' %local user metavar; ';
|
|
462
|
-
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
463
|
-
put ' %else %let metavar=_metaperson; ';
|
|
464
|
-
put ' ';
|
|
465
|
-
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
|
466
|
-
put ' %else %if %symexist(&metavar) %then %do; ';
|
|
467
|
-
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
|
468
|
-
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
|
469
|
-
put ' /* but be sure to quote in case of usernames with commas */ ';
|
|
470
|
-
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
|
471
|
-
put ' %end; ';
|
|
472
|
-
put ' %else %let user=&sysuserid; ';
|
|
473
|
-
put ' ';
|
|
474
|
-
put ' %quote(&user) ';
|
|
475
|
-
put ' ';
|
|
476
|
-
put '%mend mf_getuser; ';
|
|
477
477
|
/* WEBOUT END */
|
|
478
478
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
|
479
479
|
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
Usage:
|
|
14
14
|
|
|
15
|
-
%mfs_httpheader(Content-
|
|
15
|
+
%mfs_httpheader(Content-Type,application/csv)
|
|
16
16
|
|
|
17
17
|
@param [in] header_name Name of the http header to set
|
|
18
18
|
@param [in] header_value Value of the http header to set
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
%macro mfs_httpheader(header_name
|
|
29
29
|
,header_value
|
|
30
30
|
)/*/STORE SOURCE*/;
|
|
31
|
+
%global sasjs_stpsrv_header_loc;
|
|
31
32
|
%local fref fid i;
|
|
32
33
|
|
|
33
34
|
%if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do;
|