@sasjs/core 3.7.3 → 3.8.1
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 +7 -0
- package/base/mp_abort.sas +5 -2
- package/base/mp_applyformats.sas +2 -2
- package/base/mp_jsonout.sas +28 -13
- package/meta/mm_createwebservice.sas +24 -7
- package/meta/mm_webout.sas +9 -7
- package/package.json +1 -1
- package/server/ms_webout.sas +9 -7
- package/viya/mv_createwebservice.sas +27 -10
- package/viya/mv_webout.sas +11 -9
package/README.md
CHANGED
|
@@ -188,6 +188,13 @@ When contributing to this library, it is therefore important to ensure that all
|
|
|
188
188
|
|
|
189
189
|
- All macros should be compatible with SAS versions from support level B and above (so currently 9.2 and later). If an earlier version is not supported, then the macro should say as such in the header documentation, and exit gracefully (eg `%if %sysevalf(&sysver<9.3) %then %return`).
|
|
190
190
|
|
|
191
|
+
## Breaking Changes
|
|
192
|
+
|
|
193
|
+
We are currently on major release v3. The following changes are planned when the next major (breaking) release becomes necessary:
|
|
194
|
+
|
|
195
|
+
* Remove `dbg` parameter from mp_jsonout.sas (implement mdebug instead)
|
|
196
|
+
* Remove `END_DTTM` and `START_DTTM` from mx_webout JSON
|
|
197
|
+
|
|
191
198
|
## Star Gazing
|
|
192
199
|
|
|
193
200
|
If you find this library useful, please leave a [star](https://github.com/sasjs/core/stargazers) and help us grow our star graph!
|
package/base/mp_abort.sas
CHANGED
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
%if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
|
|
111
111
|
%else %let logloc=%qsysfunc(getoption(LOG));
|
|
112
112
|
proc printto log=log;run;
|
|
113
|
+
%let logline=0;
|
|
113
114
|
%if %length(&logloc)>0 %then %do;
|
|
114
|
-
%let logline=0;
|
|
115
115
|
data _null_;
|
|
116
116
|
infile &logloc lrecl=5000;
|
|
117
117
|
input; putlog _infile_;
|
|
@@ -160,7 +160,10 @@
|
|
|
160
160
|
file _webout mod lrecl=32000 encoding='utf-8';
|
|
161
161
|
length msg $32767 ;
|
|
162
162
|
sasdatetime=datetime();
|
|
163
|
-
msg=
|
|
163
|
+
msg=symget('msg');
|
|
164
|
+
%if &logline>0 %then %do;
|
|
165
|
+
msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
|
|
166
|
+
%end;
|
|
164
167
|
/* escape the quotes */
|
|
165
168
|
msg=tranwrd(msg,'"','\"');
|
|
166
169
|
/* ditch the CRLFs as chrome complains */
|
package/base/mp_applyformats.sas
CHANGED
|
@@ -142,16 +142,16 @@ run;
|
|
|
142
142
|
proc sql noprint;
|
|
143
143
|
select distinct lib into: liblist separated by ' ' from &inds;
|
|
144
144
|
%put &=liblist;
|
|
145
|
-
%do i=1 %to %sysfunc(countw(&liblist));
|
|
145
|
+
%if %length(&liblist)>0 %then %do i=1 %to %sysfunc(countw(&liblist));
|
|
146
146
|
%let lib=%scan(&liblist,1);
|
|
147
147
|
%let engine=%mf_getengine(&lib);
|
|
148
148
|
%if &engine ne V9 and &engine ne BASE %then %do;
|
|
149
149
|
%let msg=&lib has &engine engine - formats cannot be applied;
|
|
150
|
-
proc sql;
|
|
151
150
|
insert into &outds set lib="&lib",ds="_all_",var="_all", msg="&msg" ;
|
|
152
151
|
%if &errds=0 %then %put %str(ERR)OR: &msg;
|
|
153
152
|
%end;
|
|
154
153
|
%end;
|
|
154
|
+
quit;
|
|
155
155
|
|
|
156
156
|
%if %mf_nobs(&outds)>0 %then %return;
|
|
157
157
|
|
package/base/mp_jsonout.sas
CHANGED
|
@@ -31,22 +31,20 @@
|
|
|
31
31
|
[sasjs adapter](https://github.com/sasjs/adapter).
|
|
32
32
|
For more information see https://sasjs.io
|
|
33
33
|
|
|
34
|
-
@param action Valid values:
|
|
34
|
+
@param [in] action Valid values:
|
|
35
35
|
@li OPEN - opens the JSON
|
|
36
36
|
@li OBJ - sends a table with each row as an object
|
|
37
37
|
@li ARR - sends a table with each row in an array
|
|
38
38
|
@li CLOSE - closes the JSON
|
|
39
|
-
|
|
40
|
-
@param
|
|
41
|
-
@param
|
|
42
|
-
@param
|
|
43
|
-
@param
|
|
44
|
-
@param engine= Which engine to use to send the JSON, valid options are:
|
|
39
|
+
@param [in] ds The dataset to send. Must be a work table.
|
|
40
|
+
@param [out] jref= (_webout) The fileref to which to send the JSON
|
|
41
|
+
@param [out] dslabel= The name to give the table in the exported JSON
|
|
42
|
+
@param [in] fmt= (Y) Whether to keep (Y) or strip (N) formats from the table
|
|
43
|
+
@param [in] engine= (DATASTEP) Which engine to use to send the JSON. Options:
|
|
45
44
|
@li PROCJSON (default)
|
|
46
45
|
@li DATASTEP (more reliable when data has non standard characters)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
proc json but this can cause line truncation in large files.
|
|
46
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
47
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
50
48
|
|
|
51
49
|
<h4> Related Macros <h4>
|
|
52
50
|
@li mp_ds2fmtds.sas
|
|
@@ -57,9 +55,11 @@
|
|
|
57
55
|
|
|
58
56
|
**/
|
|
59
57
|
|
|
60
|
-
%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP
|
|
58
|
+
%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP
|
|
59
|
+
,dbg=0 /* DEPRECATED */
|
|
60
|
+
,missing=NULL
|
|
61
61
|
)/*/STORE SOURCE*/;
|
|
62
|
-
%put output location=&jref;
|
|
62
|
+
%put &sysmacroname: output location=&jref;
|
|
63
63
|
%if &action=OPEN %then %do;
|
|
64
64
|
options nobomfile;
|
|
65
65
|
data _null_;file &jref encoding='utf-8' ;
|
|
@@ -72,10 +72,16 @@
|
|
|
72
72
|
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
|
73
73
|
|
|
74
74
|
%if &engine=PROCJSON %then %do;
|
|
75
|
+
%if &missing=STRING %then %do;
|
|
76
|
+
%put &sysmacroname: Special Missings are not supported in proc json.;
|
|
77
|
+
%put &sysmacroname: Switching to DATASTEP engine;
|
|
78
|
+
%goto datastep;
|
|
79
|
+
%end;
|
|
75
80
|
data;run;%let tempds=&syslast;
|
|
76
81
|
proc sql;drop table &tempds;
|
|
77
82
|
data &tempds /view=&tempds;set &ds;
|
|
78
83
|
%if &fmt=N %then format _numeric_ best32.;;
|
|
84
|
+
/* PRETTY is necessary to avoid line truncation in large files */
|
|
79
85
|
proc json out=&jref pretty
|
|
80
86
|
%if &action=ARR %then nokeys ;
|
|
81
87
|
;export &tempds / nosastags fmtnumeric;
|
|
@@ -83,6 +89,7 @@
|
|
|
83
89
|
proc sql;drop view &tempds;
|
|
84
90
|
%end;
|
|
85
91
|
%else %if &engine=DATASTEP %then %do;
|
|
92
|
+
%datastep:
|
|
86
93
|
%local cols i tempds;
|
|
87
94
|
%let cols=0;
|
|
88
95
|
%if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 %then %do;
|
|
@@ -163,7 +170,15 @@
|
|
|
163
170
|
run;
|
|
164
171
|
|
|
165
172
|
proc format; /* credit yabwon for special null removal */
|
|
166
|
-
|
|
173
|
+
value bart
|
|
174
|
+
%if &missing=NULL %then %do;
|
|
175
|
+
._ - .z = null
|
|
176
|
+
%end;
|
|
177
|
+
%else %do;
|
|
178
|
+
._ = [quote()]
|
|
179
|
+
. = null
|
|
180
|
+
.a - .z = [quote()]
|
|
181
|
+
%end;
|
|
167
182
|
other = [best.];
|
|
168
183
|
|
|
169
184
|
data;run; %let tempds=&syslast; /* temp table for spesh char management */
|
|
@@ -89,9 +89,11 @@ data _null_;
|
|
|
89
89
|
put "/* Created on %sysfunc(datetime(),datetime19.) by %mf_getuser() */";
|
|
90
90
|
/* WEBOUT BEGIN */
|
|
91
91
|
put ' ';
|
|
92
|
-
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP
|
|
92
|
+
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP ';
|
|
93
|
+
put ' ,dbg=0 /* DEPRECATED */ ';
|
|
94
|
+
put ' ,missing=NULL ';
|
|
93
95
|
put ')/*/STORE SOURCE*/; ';
|
|
94
|
-
put '%put output location=&jref; ';
|
|
96
|
+
put '%put &sysmacroname: output location=&jref; ';
|
|
95
97
|
put '%if &action=OPEN %then %do; ';
|
|
96
98
|
put ' options nobomfile; ';
|
|
97
99
|
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
@@ -104,10 +106,16 @@ data _null_;
|
|
|
104
106
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
105
107
|
put ' ';
|
|
106
108
|
put ' %if &engine=PROCJSON %then %do; ';
|
|
109
|
+
put ' %if &missing=STRING %then %do; ';
|
|
110
|
+
put ' %put &sysmacroname: Special Missings are not supported in proc json.; ';
|
|
111
|
+
put ' %put &sysmacroname: Switching to DATASTEP engine; ';
|
|
112
|
+
put ' %goto datastep; ';
|
|
113
|
+
put ' %end; ';
|
|
107
114
|
put ' data;run;%let tempds=&syslast; ';
|
|
108
115
|
put ' proc sql;drop table &tempds; ';
|
|
109
116
|
put ' data &tempds /view=&tempds;set &ds; ';
|
|
110
117
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
118
|
+
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
111
119
|
put ' proc json out=&jref pretty ';
|
|
112
120
|
put ' %if &action=ARR %then nokeys ; ';
|
|
113
121
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
@@ -115,6 +123,7 @@ data _null_;
|
|
|
115
123
|
put ' proc sql;drop view &tempds; ';
|
|
116
124
|
put ' %end; ';
|
|
117
125
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
126
|
+
put ' %datastep: ';
|
|
118
127
|
put ' %local cols i tempds; ';
|
|
119
128
|
put ' %let cols=0; ';
|
|
120
129
|
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 %then %do; ';
|
|
@@ -195,7 +204,15 @@ data _null_;
|
|
|
195
204
|
put ' run; ';
|
|
196
205
|
put ' ';
|
|
197
206
|
put ' proc format; /* credit yabwon for special null removal */ ';
|
|
198
|
-
put '
|
|
207
|
+
put ' value bart ';
|
|
208
|
+
put ' %if &missing=NULL %then %do; ';
|
|
209
|
+
put ' ._ - .z = null ';
|
|
210
|
+
put ' %end; ';
|
|
211
|
+
put ' %else %do; ';
|
|
212
|
+
put ' ._ = [quote()] ';
|
|
213
|
+
put ' . = null ';
|
|
214
|
+
put ' .a - .z = [quote()] ';
|
|
215
|
+
put ' %end; ';
|
|
199
216
|
put ' other = [best.]; ';
|
|
200
217
|
put ' ';
|
|
201
218
|
put ' data;run; %let tempds=&syslast; /* temp table for spesh char management */ ';
|
|
@@ -263,7 +280,7 @@ data _null_;
|
|
|
263
280
|
put ' run; ';
|
|
264
281
|
put '%end; ';
|
|
265
282
|
put '%mend mp_jsonout; ';
|
|
266
|
-
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y); ';
|
|
283
|
+
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL); ';
|
|
267
284
|
put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
|
|
268
285
|
put ' sasjs_tables; ';
|
|
269
286
|
put '%local i tempds jsonengine; ';
|
|
@@ -328,7 +345,7 @@ data _null_;
|
|
|
328
345
|
put ' ';
|
|
329
346
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
330
347
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref ';
|
|
331
|
-
put ' ,engine=&jsonengine,
|
|
348
|
+
put ' ,engine=&jsonengine,missing=&missing ';
|
|
332
349
|
put ' ) ';
|
|
333
350
|
put '%end; ';
|
|
334
351
|
put '%else %if &action=CLOSE %then %do; ';
|
|
@@ -418,8 +435,8 @@ data _null_;
|
|
|
418
435
|
put ' ';
|
|
419
436
|
put '%mend mf_getuser; ';
|
|
420
437
|
/* WEBOUT END */
|
|
421
|
-
put '%macro webout(action,ds,dslabel=,fmt=);';
|
|
422
|
-
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt)';
|
|
438
|
+
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
|
439
|
+
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
|
423
440
|
put '%mend;';
|
|
424
441
|
run;
|
|
425
442
|
|
package/meta/mm_webout.sas
CHANGED
|
@@ -23,17 +23,19 @@
|
|
|
23
23
|
%mm_webout(CLOSE)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
@param action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
27
|
-
@param ds The dataset to send back to the frontend
|
|
28
|
-
@param dslabel=
|
|
29
|
-
@param fmt=(Y) Set to N to send back unformatted values
|
|
30
|
-
@param fref=(_webout) The fileref to which to write the JSON
|
|
26
|
+
@param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
27
|
+
@param [in] ds The dataset to send back to the frontend
|
|
28
|
+
@param [out] dslabel= Value to use instead of table name for sending to JSON
|
|
29
|
+
@param [in] fmt=(Y) Set to N to send back unformatted values
|
|
30
|
+
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
31
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
32
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
31
33
|
|
|
32
34
|
@version 9.3
|
|
33
35
|
@author Allan Bowe
|
|
34
36
|
|
|
35
37
|
**/
|
|
36
|
-
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y);
|
|
38
|
+
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL);
|
|
37
39
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
38
40
|
sasjs_tables;
|
|
39
41
|
%local i tempds jsonengine;
|
|
@@ -98,7 +100,7 @@
|
|
|
98
100
|
|
|
99
101
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
100
102
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
101
|
-
,engine=&jsonengine,
|
|
103
|
+
,engine=&jsonengine,missing=&missing
|
|
102
104
|
)
|
|
103
105
|
%end;
|
|
104
106
|
%else %if &action=CLOSE %then %do;
|
package/package.json
CHANGED
package/server/ms_webout.sas
CHANGED
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
%ms_webout(CLOSE)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@param action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
24
|
-
@param ds The dataset to send back to the frontend
|
|
25
|
-
@param dslabel= value to use instead of
|
|
26
|
-
@param fmt=(Y) Set to N to send back unformatted values
|
|
27
|
-
@param fref=(_webout) The fileref to which to write the JSON
|
|
23
|
+
@param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
24
|
+
@param [in] ds The dataset to send back to the frontend
|
|
25
|
+
@param [out] dslabel= value to use instead of table name for sending to JSON
|
|
26
|
+
@param [in] fmt= (Y) Set to N to send back unformatted values
|
|
27
|
+
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
28
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
29
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
28
30
|
|
|
29
31
|
<h4> SAS Macros </h4>
|
|
30
32
|
@li mp_jsonout.sas
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
|
|
40
42
|
**/
|
|
41
43
|
|
|
42
|
-
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y);
|
|
44
|
+
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL);
|
|
43
45
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
44
46
|
sasjs_tables;
|
|
45
47
|
|
|
@@ -91,7 +93,7 @@
|
|
|
91
93
|
|
|
92
94
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
93
95
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
94
|
-
,engine=DATASTEP,
|
|
96
|
+
,engine=DATASTEP,missing=&missing
|
|
95
97
|
)
|
|
96
98
|
%end;
|
|
97
99
|
%else %if &action=CLOSE %then %do;
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
that location
|
|
55
55
|
@param [in] adapter= the macro uses the sasjs adapter by default. To use
|
|
56
56
|
another adapter, add a (different) fileref here.
|
|
57
|
-
@param [in] contextname= Choose a specific context on which to run the Job.
|
|
58
|
-
blank to use the default context. From Viya 3.5 it is possible to
|
|
59
|
-
a shared context - see
|
|
57
|
+
@param [in] contextname= Choose a specific context on which to run the Job.
|
|
58
|
+
Leave blank to use the default context. From Viya 3.5 it is possible to
|
|
59
|
+
configure a shared context - see
|
|
60
60
|
https://go.documentation.sas.com/?docsetId=calcontexts&docsetTarget=n1hjn8eobk5pyhn1wg3ja0drdl6h.htm&docsetVersion=3.5&locale=en
|
|
61
61
|
@param [in] mdebug=(0) set to 1 to enable DEBUG messages
|
|
62
62
|
|
|
@@ -237,9 +237,11 @@ data _null_;
|
|
|
237
237
|
put "/* Created on %sysfunc(datetime(),datetime19.) by &sysuserid */";
|
|
238
238
|
/* WEBOUT BEGIN */
|
|
239
239
|
put ' ';
|
|
240
|
-
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP
|
|
240
|
+
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y,engine=DATASTEP ';
|
|
241
|
+
put ' ,dbg=0 /* DEPRECATED */ ';
|
|
242
|
+
put ' ,missing=NULL ';
|
|
241
243
|
put ')/*/STORE SOURCE*/; ';
|
|
242
|
-
put '%put output location=&jref; ';
|
|
244
|
+
put '%put &sysmacroname: output location=&jref; ';
|
|
243
245
|
put '%if &action=OPEN %then %do; ';
|
|
244
246
|
put ' options nobomfile; ';
|
|
245
247
|
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
@@ -252,10 +254,16 @@ data _null_;
|
|
|
252
254
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
253
255
|
put ' ';
|
|
254
256
|
put ' %if &engine=PROCJSON %then %do; ';
|
|
257
|
+
put ' %if &missing=STRING %then %do; ';
|
|
258
|
+
put ' %put &sysmacroname: Special Missings are not supported in proc json.; ';
|
|
259
|
+
put ' %put &sysmacroname: Switching to DATASTEP engine; ';
|
|
260
|
+
put ' %goto datastep; ';
|
|
261
|
+
put ' %end; ';
|
|
255
262
|
put ' data;run;%let tempds=&syslast; ';
|
|
256
263
|
put ' proc sql;drop table &tempds; ';
|
|
257
264
|
put ' data &tempds /view=&tempds;set &ds; ';
|
|
258
265
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
266
|
+
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
259
267
|
put ' proc json out=&jref pretty ';
|
|
260
268
|
put ' %if &action=ARR %then nokeys ; ';
|
|
261
269
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
@@ -263,6 +271,7 @@ data _null_;
|
|
|
263
271
|
put ' proc sql;drop view &tempds; ';
|
|
264
272
|
put ' %end; ';
|
|
265
273
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
274
|
+
put ' %datastep: ';
|
|
266
275
|
put ' %local cols i tempds; ';
|
|
267
276
|
put ' %let cols=0; ';
|
|
268
277
|
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 %then %do; ';
|
|
@@ -343,7 +352,15 @@ data _null_;
|
|
|
343
352
|
put ' run; ';
|
|
344
353
|
put ' ';
|
|
345
354
|
put ' proc format; /* credit yabwon for special null removal */ ';
|
|
346
|
-
put '
|
|
355
|
+
put ' value bart ';
|
|
356
|
+
put ' %if &missing=NULL %then %do; ';
|
|
357
|
+
put ' ._ - .z = null ';
|
|
358
|
+
put ' %end; ';
|
|
359
|
+
put ' %else %do; ';
|
|
360
|
+
put ' ._ = [quote()] ';
|
|
361
|
+
put ' . = null ';
|
|
362
|
+
put ' .a - .z = [quote()] ';
|
|
363
|
+
put ' %end; ';
|
|
347
364
|
put ' other = [best.]; ';
|
|
348
365
|
put ' ';
|
|
349
366
|
put ' data;run; %let tempds=&syslast; /* temp table for spesh char management */ ';
|
|
@@ -411,7 +428,7 @@ data _null_;
|
|
|
411
428
|
put ' run; ';
|
|
412
429
|
put '%end; ';
|
|
413
430
|
put '%mend mp_jsonout; ';
|
|
414
|
-
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y); ';
|
|
431
|
+
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL); ';
|
|
415
432
|
put '%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name ';
|
|
416
433
|
put ' sasjs_tables SYS_JES_JOB_URI; ';
|
|
417
434
|
put '%if %index("&_debug",log) %then %let _debug=131; ';
|
|
@@ -538,7 +555,7 @@ data _null_;
|
|
|
538
555
|
put '%end; ';
|
|
539
556
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
540
557
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
|
541
|
-
put ' ,jref=&fref,engine=DATASTEP,
|
|
558
|
+
put ' ,jref=&fref,engine=DATASTEP,missing=&missing ';
|
|
542
559
|
put ' ) ';
|
|
543
560
|
put '%end; ';
|
|
544
561
|
put '%else %if &action=CLOSE %then %do; ';
|
|
@@ -629,8 +646,8 @@ data _null_;
|
|
|
629
646
|
put '%global __program _program;';
|
|
630
647
|
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
|
631
648
|
put ' ';
|
|
632
|
-
put '%macro webout(action,ds,dslabel=,fmt=);';
|
|
633
|
-
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt)';
|
|
649
|
+
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
|
650
|
+
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
|
634
651
|
put '%mend;';
|
|
635
652
|
run;
|
|
636
653
|
|
package/viya/mv_webout.sas
CHANGED
|
@@ -20,13 +20,15 @@
|
|
|
20
20
|
%mv_webout(CLOSE)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@param action Either OPEN, ARR, OBJ or CLOSE
|
|
24
|
-
@param ds The dataset to send back to the frontend
|
|
25
|
-
@param _webout= fileref for returning the json
|
|
26
|
-
@param fref=(_mvwtemp) Temp fileref to which to write the output
|
|
27
|
-
@param dslabel= value to use instead of
|
|
28
|
-
@param fmt=(Y) change to N to strip formats from output
|
|
29
|
-
@param stream=(Y) Change to N if not streaming to _webout
|
|
23
|
+
@param [in] action Either OPEN, ARR, OBJ or CLOSE
|
|
24
|
+
@param [in] ds The dataset to send back to the frontend
|
|
25
|
+
@param [in] _webout= fileref for returning the json
|
|
26
|
+
@param [out] fref=(_mvwtemp) Temp fileref to which to write the output
|
|
27
|
+
@param [out] dslabel= value to use instead of table name for sending to JSON
|
|
28
|
+
@param [in] fmt=(Y) change to N to strip formats from output
|
|
29
|
+
@param [in] stream=(Y) Change to N if not streaming to _webout
|
|
30
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
31
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
30
32
|
|
|
31
33
|
<h4> SAS Macros </h4>
|
|
32
34
|
@li mp_jsonout.sas
|
|
@@ -36,7 +38,7 @@
|
|
|
36
38
|
@author Allan Bowe, source: https://github.com/sasjs/core
|
|
37
39
|
|
|
38
40
|
**/
|
|
39
|
-
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y);
|
|
41
|
+
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL);
|
|
40
42
|
%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
|
|
41
43
|
sasjs_tables SYS_JES_JOB_URI;
|
|
42
44
|
%if %index("&_debug",log) %then %let _debug=131;
|
|
@@ -163,7 +165,7 @@
|
|
|
163
165
|
%end;
|
|
164
166
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
165
167
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
|
166
|
-
,jref=&fref,engine=DATASTEP,
|
|
168
|
+
,jref=&fref,engine=DATASTEP,missing=&missing
|
|
167
169
|
)
|
|
168
170
|
%end;
|
|
169
171
|
%else %if &action=CLOSE %then %do;
|