@sasjs/core 4.32.1 → 4.32.2
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/mp_jsonout.sas +59 -16
- package/meta/mm_createwebservice.sas +67 -21
- package/meta/mm_webout.sas +34 -18
- package/package.json +1 -1
- package/server/ms_createwebservice.sas +49 -15
- package/viya/mv_createwebservice.sas +49 -15
package/base/mp_jsonout.sas
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file mp_jsonout.sas
|
|
3
3
|
@brief Writes JSON in SASjs format to a fileref
|
|
4
|
-
@details
|
|
4
|
+
@details This macro can be used to OPEN a JSON stream and send one or more
|
|
5
|
+
tables as arrays of rows, where each row can be an object or a nested array.
|
|
6
|
+
|
|
7
|
+
There are two engines available - DATASTEP or PROCJSON.
|
|
8
|
+
|
|
9
|
+
PROC JSON is fast but will produce errs like the ones below if
|
|
5
10
|
special chars are encountered.
|
|
6
11
|
|
|
7
12
|
> (ERR)OR: Some code points did not transcode.
|
|
@@ -12,6 +17,10 @@
|
|
|
12
17
|
|
|
13
18
|
If this happens, try running with ENGINE=DATASTEP.
|
|
14
19
|
|
|
20
|
+
The DATASTEP engine is used to handle special SAS missing numerics, and
|
|
21
|
+
can also convert entire datasets to formatted values. Output JSON is always
|
|
22
|
+
in UTF-8.
|
|
23
|
+
|
|
15
24
|
Usage:
|
|
16
25
|
|
|
17
26
|
filename tmp temp;
|
|
@@ -75,9 +84,23 @@
|
|
|
75
84
|
run;
|
|
76
85
|
%end;
|
|
77
86
|
%else %if (&action=ARR or &action=OBJ) %then %do;
|
|
87
|
+
/* force variable names to always be uppercase in the JSON */
|
|
78
88
|
options validvarname=upcase;
|
|
79
|
-
|
|
89
|
+
/* To avoid issues with _webout on EBI - such as encoding diffs and truncation
|
|
90
|
+
(https://support.sas.com/kb/49/325.html) we use temporary files */
|
|
91
|
+
filename _sjs1 temp lrecl=200 ;
|
|
92
|
+
data _null_; file _sjs1 encoding='utf-8';
|
|
80
93
|
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
|
94
|
+
run;
|
|
95
|
+
/* now write to _webout 1 char at a time */
|
|
96
|
+
data _null_;
|
|
97
|
+
infile _sjs1 lrecl=1 recfm=n;
|
|
98
|
+
file &jref mod lrecl=1 recfm=n;
|
|
99
|
+
input sourcechar $char1. @@;
|
|
100
|
+
format sourcechar hex2.;
|
|
101
|
+
put sourcechar char1. @@;
|
|
102
|
+
run;
|
|
103
|
+
filename _sjs1 clear;
|
|
81
104
|
|
|
82
105
|
/* grab col defs */
|
|
83
106
|
proc contents noprint data=&ds
|
|
@@ -134,10 +157,20 @@
|
|
|
134
157
|
data &tempds;set &ds;
|
|
135
158
|
%if &fmt=N %then format _numeric_ best32.;;
|
|
136
159
|
/* PRETTY is necessary to avoid line truncation in large files */
|
|
137
|
-
|
|
160
|
+
filename _sjs2 temp lrecl=131068 encoding='utf-8';
|
|
161
|
+
proc json out=_sjs2 pretty
|
|
138
162
|
%if &action=ARR %then nokeys ;
|
|
139
163
|
;export &tempds / nosastags fmtnumeric;
|
|
140
164
|
run;
|
|
165
|
+
/* send back to webout */
|
|
166
|
+
data _null_;
|
|
167
|
+
infile _sjs2 lrecl=1 recfm=n;
|
|
168
|
+
file &jref mod lrecl=1 recfm=n;
|
|
169
|
+
input sourcechar $char1. @@;
|
|
170
|
+
format sourcechar hex2.;
|
|
171
|
+
put sourcechar char1. @@;
|
|
172
|
+
run;
|
|
173
|
+
filename _sjs2 clear;
|
|
141
174
|
%end;
|
|
142
175
|
%else %if &engine=DATASTEP %then %do;
|
|
143
176
|
%datastep:
|
|
@@ -220,10 +253,9 @@
|
|
|
220
253
|
%end;
|
|
221
254
|
run;
|
|
222
255
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
data _null_; file _sjs lrecl=131068 encoding='utf-8' mod ;
|
|
256
|
+
filename _sjs3 temp lrecl=131068 ;
|
|
257
|
+
data _null_;
|
|
258
|
+
file _sjs3 encoding='utf-8';
|
|
227
259
|
if _n_=1 then put "[";
|
|
228
260
|
set &tempds;
|
|
229
261
|
if _n_>1 then put "," @; put
|
|
@@ -234,27 +266,29 @@
|
|
|
234
266
|
"&&name&i"n /* name literal for reserved variable names */
|
|
235
267
|
%end;
|
|
236
268
|
%if &action=ARR %then "]" ; %else "}" ; ;
|
|
237
|
-
|
|
269
|
+
|
|
270
|
+
/* close out the table */
|
|
238
271
|
data _null_;
|
|
239
|
-
|
|
272
|
+
file _sjs3 mod encoding='utf-8';
|
|
273
|
+
put ']';
|
|
274
|
+
run;
|
|
275
|
+
data _null_;
|
|
276
|
+
infile _sjs3 lrecl=1 recfm=n;
|
|
240
277
|
file &jref mod lrecl=1 recfm=n;
|
|
241
278
|
input sourcechar $char1. @@;
|
|
242
279
|
format sourcechar hex2.;
|
|
243
280
|
put sourcechar char1. @@;
|
|
244
281
|
run;
|
|
245
|
-
|
|
246
|
-
data _null_;
|
|
247
|
-
file &jref mod;
|
|
248
|
-
put ']';
|
|
249
|
-
run;
|
|
250
|
-
filename _sjs clear;
|
|
282
|
+
filename _sjs3 clear;
|
|
251
283
|
%end;
|
|
252
284
|
|
|
253
285
|
proc sql;
|
|
254
286
|
drop table &colinfo, &tempds;
|
|
255
287
|
|
|
256
288
|
%if &showmeta=YES %then %do;
|
|
257
|
-
|
|
289
|
+
filename _sjs4 temp lrecl=131068 encoding='utf-8';
|
|
290
|
+
data _null_;
|
|
291
|
+
file _sjs4;
|
|
258
292
|
put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{";
|
|
259
293
|
do i=1 to &numcols;
|
|
260
294
|
name=quote(trim(symget(cats('name',i))));
|
|
@@ -268,6 +302,15 @@
|
|
|
268
302
|
end;
|
|
269
303
|
put '}}';
|
|
270
304
|
run;
|
|
305
|
+
/* send back to webout */
|
|
306
|
+
data _null_;
|
|
307
|
+
infile _sjs4 lrecl=1 recfm=n;
|
|
308
|
+
file &jref mod lrecl=1 recfm=n;
|
|
309
|
+
input sourcechar $char1. @@;
|
|
310
|
+
format sourcechar hex2.;
|
|
311
|
+
put sourcechar char1. @@;
|
|
312
|
+
run;
|
|
313
|
+
filename _sjs4 clear;
|
|
271
314
|
%end;
|
|
272
315
|
%end;
|
|
273
316
|
|
|
@@ -109,9 +109,23 @@ data _null_;
|
|
|
109
109
|
put ' run; ';
|
|
110
110
|
put '%end; ';
|
|
111
111
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
112
|
+
put ' /* force variable names to always be uppercase in the JSON */ ';
|
|
112
113
|
put ' options validvarname=upcase; ';
|
|
113
|
-
put '
|
|
114
|
+
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
|
115
|
+
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
|
116
|
+
put ' filename _sjs1 temp lrecl=200 ; ';
|
|
117
|
+
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
|
114
118
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
119
|
+
put ' run; ';
|
|
120
|
+
put ' /* now write to _webout 1 char at a time */ ';
|
|
121
|
+
put ' data _null_; ';
|
|
122
|
+
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
|
123
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
124
|
+
put ' input sourcechar $char1. @@; ';
|
|
125
|
+
put ' format sourcechar hex2.; ';
|
|
126
|
+
put ' put sourcechar char1. @@; ';
|
|
127
|
+
put ' run; ';
|
|
128
|
+
put ' filename _sjs1 clear; ';
|
|
115
129
|
put ' ';
|
|
116
130
|
put ' /* grab col defs */ ';
|
|
117
131
|
put ' proc contents noprint data=&ds ';
|
|
@@ -168,10 +182,20 @@ data _null_;
|
|
|
168
182
|
put ' data &tempds;set &ds; ';
|
|
169
183
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
170
184
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
171
|
-
put '
|
|
185
|
+
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
|
186
|
+
put ' proc json out=_sjs2 pretty ';
|
|
172
187
|
put ' %if &action=ARR %then nokeys ; ';
|
|
173
188
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
174
189
|
put ' run; ';
|
|
190
|
+
put ' /* send back to webout */ ';
|
|
191
|
+
put ' data _null_; ';
|
|
192
|
+
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
|
193
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
194
|
+
put ' input sourcechar $char1. @@; ';
|
|
195
|
+
put ' format sourcechar hex2.; ';
|
|
196
|
+
put ' put sourcechar char1. @@; ';
|
|
197
|
+
put ' run; ';
|
|
198
|
+
put ' filename _sjs2 clear; ';
|
|
175
199
|
put ' %end; ';
|
|
176
200
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
177
201
|
put ' %datastep: ';
|
|
@@ -254,10 +278,9 @@ data _null_;
|
|
|
254
278
|
put ' %end; ';
|
|
255
279
|
put ' run; ';
|
|
256
280
|
put ' ';
|
|
257
|
-
put '
|
|
258
|
-
put '
|
|
259
|
-
put '
|
|
260
|
-
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
281
|
+
put ' filename _sjs3 temp lrecl=131068 ; ';
|
|
282
|
+
put ' data _null_; ';
|
|
283
|
+
put ' file _sjs3 encoding=''utf-8''; ';
|
|
261
284
|
put ' if _n_=1 then put "["; ';
|
|
262
285
|
put ' set &tempds; ';
|
|
263
286
|
put ' if _n_>1 then put "," @; put ';
|
|
@@ -268,27 +291,29 @@ data _null_;
|
|
|
268
291
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
|
269
292
|
put ' %end; ';
|
|
270
293
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
271
|
-
put '
|
|
294
|
+
put ' ';
|
|
295
|
+
put ' /* close out the table */ ';
|
|
296
|
+
put ' data _null_; ';
|
|
297
|
+
put ' file _sjs3 mod encoding=''utf-8''; ';
|
|
298
|
+
put ' put '']''; ';
|
|
299
|
+
put ' run; ';
|
|
272
300
|
put ' data _null_; ';
|
|
273
|
-
put ' infile
|
|
301
|
+
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
|
274
302
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
275
303
|
put ' input sourcechar $char1. @@; ';
|
|
276
304
|
put ' format sourcechar hex2.; ';
|
|
277
305
|
put ' put sourcechar char1. @@; ';
|
|
278
306
|
put ' run; ';
|
|
279
|
-
put '
|
|
280
|
-
put ' data _null_; ';
|
|
281
|
-
put ' file &jref mod; ';
|
|
282
|
-
put ' put '']''; ';
|
|
283
|
-
put ' run; ';
|
|
284
|
-
put ' filename _sjs clear; ';
|
|
307
|
+
put ' filename _sjs3 clear; ';
|
|
285
308
|
put ' %end; ';
|
|
286
309
|
put ' ';
|
|
287
310
|
put ' proc sql; ';
|
|
288
311
|
put ' drop table &colinfo, &tempds; ';
|
|
289
312
|
put ' ';
|
|
290
313
|
put ' %if &showmeta=YES %then %do; ';
|
|
291
|
-
put '
|
|
314
|
+
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
|
315
|
+
put ' data _null_; ';
|
|
316
|
+
put ' file _sjs4; ';
|
|
292
317
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
|
293
318
|
put ' do i=1 to &numcols; ';
|
|
294
319
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
|
@@ -302,6 +327,15 @@ data _null_;
|
|
|
302
327
|
put ' end; ';
|
|
303
328
|
put ' put ''}}''; ';
|
|
304
329
|
put ' run; ';
|
|
330
|
+
put ' /* send back to webout */ ';
|
|
331
|
+
put ' data _null_; ';
|
|
332
|
+
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
|
333
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
334
|
+
put ' input sourcechar $char1. @@; ';
|
|
335
|
+
put ' format sourcechar hex2.; ';
|
|
336
|
+
put ' put sourcechar char1. @@; ';
|
|
337
|
+
put ' run; ';
|
|
338
|
+
put ' filename _sjs4 clear; ';
|
|
305
339
|
put ' %end; ';
|
|
306
340
|
put '%end; ';
|
|
307
341
|
put ' ';
|
|
@@ -403,6 +437,8 @@ data _null_;
|
|
|
403
437
|
put ' ) ';
|
|
404
438
|
put '%end; ';
|
|
405
439
|
put '%else %if &action=CLOSE %then %do; ';
|
|
440
|
+
put ' /* To avoid issues with _webout on EBI we use a temporary file */ ';
|
|
441
|
+
put ' filename _sjsref temp lrecl=131068; ';
|
|
406
442
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
|
407
443
|
put ' /* if debug mode, send back first 10 records of each work table also */ ';
|
|
408
444
|
put ' options obs=10; ';
|
|
@@ -416,11 +452,11 @@ data _null_;
|
|
|
416
452
|
put ' i+1; ';
|
|
417
453
|
put ' call symputx(cats(''wt'',i),name,''l''); ';
|
|
418
454
|
put ' call symputx(''wtcnt'',i,''l''); ';
|
|
419
|
-
put ' data _null_; file
|
|
455
|
+
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
|
420
456
|
put ' put ",""WORK"":{"; ';
|
|
421
457
|
put ' %do i=1 %to &wtcnt; ';
|
|
422
458
|
put ' %let wt=&&wt&i; ';
|
|
423
|
-
put ' data _null_; file
|
|
459
|
+
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
|
424
460
|
put ' dsid=open("WORK.&wt",''is''); ';
|
|
425
461
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
|
426
462
|
put ' nvars=attrn(dsid,''NVARS''); ';
|
|
@@ -429,16 +465,16 @@ data _null_;
|
|
|
429
465
|
put ' put " ""&wt"" : {"; ';
|
|
430
466
|
put ' put ''"nlobs":'' nlobs; ';
|
|
431
467
|
put ' put '',"nvars":'' nvars; ';
|
|
432
|
-
put ' %mp_jsonout(OBJ,&wt,jref
|
|
433
|
-
put ' data _null_; file
|
|
468
|
+
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES) ';
|
|
469
|
+
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
|
434
470
|
put ' put "}"; ';
|
|
435
471
|
put ' %end; ';
|
|
436
|
-
put ' data _null_; file
|
|
472
|
+
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
|
437
473
|
put ' put "}"; ';
|
|
438
474
|
put ' run; ';
|
|
439
475
|
put ' %end; ';
|
|
440
476
|
put ' /* close off json */ ';
|
|
441
|
-
put ' data _null_;file
|
|
477
|
+
put ' data _null_;file _sjsref mod encoding=''utf-8''; ';
|
|
442
478
|
put ' _PROGRAM=quote(trim(resolve(symget(''_PROGRAM'')))); ';
|
|
443
479
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
|
444
480
|
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
|
@@ -470,6 +506,16 @@ data _null_;
|
|
|
470
506
|
put ' put ''>>weboutEND<<''; ';
|
|
471
507
|
put ' %end; ';
|
|
472
508
|
put ' run; ';
|
|
509
|
+
put ' /* now write to _webout 1 char at a time */ ';
|
|
510
|
+
put ' data _null_; ';
|
|
511
|
+
put ' infile _sjsref lrecl=1 recfm=n; ';
|
|
512
|
+
put ' file &fref mod lrecl=1 recfm=n; ';
|
|
513
|
+
put ' input sourcechar $char1. @@; ';
|
|
514
|
+
put ' format sourcechar hex2.; ';
|
|
515
|
+
put ' put sourcechar char1. @@; ';
|
|
516
|
+
put ' run; ';
|
|
517
|
+
put ' filename _sjsref clear; ';
|
|
518
|
+
put ' ';
|
|
473
519
|
put '%end; ';
|
|
474
520
|
put ' ';
|
|
475
521
|
put '%mend mm_webout; ';
|
package/meta/mm_webout.sas
CHANGED
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
@details This macro should be added to the start of each Stored Process,
|
|
5
5
|
**immediately** followed by a call to:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
%mm_webout(FETCH)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
This will read all the input data and create same-named SAS datasets in the
|
|
10
|
+
WORK library. You can then insert your code, and send data back using the
|
|
11
|
+
following syntax:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
data some datasets; * make some data ;
|
|
14
|
+
retain some columns;
|
|
15
|
+
run;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
%mm_webout(OPEN)
|
|
18
|
+
%mm_webout(ARR,some) * Array format, fast, suitable for large tables ;
|
|
19
|
+
%mm_webout(OBJ,datasets) * Object format, easier to work with ;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Finally, wrap everything up send some helpful system variables too
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
%mm_webout(CLOSE)
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
@param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
object with the same name as the table but prefixed with a dollar sign - ie,
|
|
36
36
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
37
37
|
|
|
38
|
+
|
|
39
|
+
<h4> SAS Macros </h4>
|
|
40
|
+
@li mp_jsonout.sas
|
|
41
|
+
|
|
38
42
|
@version 9.3
|
|
39
43
|
@author Allan Bowe
|
|
40
44
|
|
|
@@ -111,6 +115,8 @@
|
|
|
111
115
|
)
|
|
112
116
|
%end;
|
|
113
117
|
%else %if &action=CLOSE %then %do;
|
|
118
|
+
/* To avoid issues with _webout on EBI we use a temporary file */
|
|
119
|
+
filename _sjsref temp lrecl=131068;
|
|
114
120
|
%if %str(&_debug) ge 131 %then %do;
|
|
115
121
|
/* if debug mode, send back first 10 records of each work table also */
|
|
116
122
|
options obs=10;
|
|
@@ -124,11 +130,11 @@
|
|
|
124
130
|
i+1;
|
|
125
131
|
call symputx(cats('wt',i),name,'l');
|
|
126
132
|
call symputx('wtcnt',i,'l');
|
|
127
|
-
data _null_; file
|
|
133
|
+
data _null_; file _sjsref mod encoding='utf-8';
|
|
128
134
|
put ",""WORK"":{";
|
|
129
135
|
%do i=1 %to &wtcnt;
|
|
130
136
|
%let wt=&&wt&i;
|
|
131
|
-
data _null_; file
|
|
137
|
+
data _null_; file _sjsref mod encoding='utf-8';
|
|
132
138
|
dsid=open("WORK.&wt",'is');
|
|
133
139
|
nlobs=attrn(dsid,'NLOBS');
|
|
134
140
|
nvars=attrn(dsid,'NVARS');
|
|
@@ -137,16 +143,16 @@
|
|
|
137
143
|
put " ""&wt"" : {";
|
|
138
144
|
put '"nlobs":' nlobs;
|
|
139
145
|
put ',"nvars":' nvars;
|
|
140
|
-
%mp_jsonout(OBJ,&wt,jref
|
|
141
|
-
data _null_; file
|
|
146
|
+
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES)
|
|
147
|
+
data _null_; file _sjsref mod encoding='utf-8';
|
|
142
148
|
put "}";
|
|
143
149
|
%end;
|
|
144
|
-
data _null_; file
|
|
150
|
+
data _null_; file _sjsref mod encoding='utf-8';
|
|
145
151
|
put "}";
|
|
146
152
|
run;
|
|
147
153
|
%end;
|
|
148
154
|
/* close off json */
|
|
149
|
-
data _null_;file
|
|
155
|
+
data _null_;file _sjsref mod encoding='utf-8';
|
|
150
156
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
|
151
157
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
|
152
158
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
|
@@ -178,6 +184,16 @@
|
|
|
178
184
|
put '>>weboutEND<<';
|
|
179
185
|
%end;
|
|
180
186
|
run;
|
|
187
|
+
/* now write to _webout 1 char at a time */
|
|
188
|
+
data _null_;
|
|
189
|
+
infile _sjsref lrecl=1 recfm=n;
|
|
190
|
+
file &fref mod lrecl=1 recfm=n;
|
|
191
|
+
input sourcechar $char1. @@;
|
|
192
|
+
format sourcechar hex2.;
|
|
193
|
+
put sourcechar char1. @@;
|
|
194
|
+
run;
|
|
195
|
+
filename _sjsref clear;
|
|
196
|
+
|
|
181
197
|
%end;
|
|
182
198
|
|
|
183
199
|
%mend mm_webout;
|
package/package.json
CHANGED
|
@@ -110,9 +110,23 @@ data _null_;
|
|
|
110
110
|
put ' run; ';
|
|
111
111
|
put '%end; ';
|
|
112
112
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
113
|
+
put ' /* force variable names to always be uppercase in the JSON */ ';
|
|
113
114
|
put ' options validvarname=upcase; ';
|
|
114
|
-
put '
|
|
115
|
+
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
|
116
|
+
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
|
117
|
+
put ' filename _sjs1 temp lrecl=200 ; ';
|
|
118
|
+
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
|
115
119
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
120
|
+
put ' run; ';
|
|
121
|
+
put ' /* now write to _webout 1 char at a time */ ';
|
|
122
|
+
put ' data _null_; ';
|
|
123
|
+
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
|
124
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
125
|
+
put ' input sourcechar $char1. @@; ';
|
|
126
|
+
put ' format sourcechar hex2.; ';
|
|
127
|
+
put ' put sourcechar char1. @@; ';
|
|
128
|
+
put ' run; ';
|
|
129
|
+
put ' filename _sjs1 clear; ';
|
|
116
130
|
put ' ';
|
|
117
131
|
put ' /* grab col defs */ ';
|
|
118
132
|
put ' proc contents noprint data=&ds ';
|
|
@@ -169,10 +183,20 @@ data _null_;
|
|
|
169
183
|
put ' data &tempds;set &ds; ';
|
|
170
184
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
171
185
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
172
|
-
put '
|
|
186
|
+
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
|
187
|
+
put ' proc json out=_sjs2 pretty ';
|
|
173
188
|
put ' %if &action=ARR %then nokeys ; ';
|
|
174
189
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
175
190
|
put ' run; ';
|
|
191
|
+
put ' /* send back to webout */ ';
|
|
192
|
+
put ' data _null_; ';
|
|
193
|
+
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
|
194
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
195
|
+
put ' input sourcechar $char1. @@; ';
|
|
196
|
+
put ' format sourcechar hex2.; ';
|
|
197
|
+
put ' put sourcechar char1. @@; ';
|
|
198
|
+
put ' run; ';
|
|
199
|
+
put ' filename _sjs2 clear; ';
|
|
176
200
|
put ' %end; ';
|
|
177
201
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
178
202
|
put ' %datastep: ';
|
|
@@ -255,10 +279,9 @@ data _null_;
|
|
|
255
279
|
put ' %end; ';
|
|
256
280
|
put ' run; ';
|
|
257
281
|
put ' ';
|
|
258
|
-
put '
|
|
259
|
-
put '
|
|
260
|
-
put '
|
|
261
|
-
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
282
|
+
put ' filename _sjs3 temp lrecl=131068 ; ';
|
|
283
|
+
put ' data _null_; ';
|
|
284
|
+
put ' file _sjs3 encoding=''utf-8''; ';
|
|
262
285
|
put ' if _n_=1 then put "["; ';
|
|
263
286
|
put ' set &tempds; ';
|
|
264
287
|
put ' if _n_>1 then put "," @; put ';
|
|
@@ -269,27 +292,29 @@ data _null_;
|
|
|
269
292
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
|
270
293
|
put ' %end; ';
|
|
271
294
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
272
|
-
put '
|
|
295
|
+
put ' ';
|
|
296
|
+
put ' /* close out the table */ ';
|
|
297
|
+
put ' data _null_; ';
|
|
298
|
+
put ' file _sjs3 mod encoding=''utf-8''; ';
|
|
299
|
+
put ' put '']''; ';
|
|
300
|
+
put ' run; ';
|
|
273
301
|
put ' data _null_; ';
|
|
274
|
-
put ' infile
|
|
302
|
+
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
|
275
303
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
276
304
|
put ' input sourcechar $char1. @@; ';
|
|
277
305
|
put ' format sourcechar hex2.; ';
|
|
278
306
|
put ' put sourcechar char1. @@; ';
|
|
279
307
|
put ' run; ';
|
|
280
|
-
put '
|
|
281
|
-
put ' data _null_; ';
|
|
282
|
-
put ' file &jref mod; ';
|
|
283
|
-
put ' put '']''; ';
|
|
284
|
-
put ' run; ';
|
|
285
|
-
put ' filename _sjs clear; ';
|
|
308
|
+
put ' filename _sjs3 clear; ';
|
|
286
309
|
put ' %end; ';
|
|
287
310
|
put ' ';
|
|
288
311
|
put ' proc sql; ';
|
|
289
312
|
put ' drop table &colinfo, &tempds; ';
|
|
290
313
|
put ' ';
|
|
291
314
|
put ' %if &showmeta=YES %then %do; ';
|
|
292
|
-
put '
|
|
315
|
+
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
|
316
|
+
put ' data _null_; ';
|
|
317
|
+
put ' file _sjs4; ';
|
|
293
318
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
|
294
319
|
put ' do i=1 to &numcols; ';
|
|
295
320
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
|
@@ -303,6 +328,15 @@ data _null_;
|
|
|
303
328
|
put ' end; ';
|
|
304
329
|
put ' put ''}}''; ';
|
|
305
330
|
put ' run; ';
|
|
331
|
+
put ' /* send back to webout */ ';
|
|
332
|
+
put ' data _null_; ';
|
|
333
|
+
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
|
334
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
335
|
+
put ' input sourcechar $char1. @@; ';
|
|
336
|
+
put ' format sourcechar hex2.; ';
|
|
337
|
+
put ' put sourcechar char1. @@; ';
|
|
338
|
+
put ' run; ';
|
|
339
|
+
put ' filename _sjs4 clear; ';
|
|
306
340
|
put ' %end; ';
|
|
307
341
|
put '%end; ';
|
|
308
342
|
put ' ';
|
|
@@ -252,9 +252,23 @@ data _null_;
|
|
|
252
252
|
put ' run; ';
|
|
253
253
|
put '%end; ';
|
|
254
254
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
255
|
+
put ' /* force variable names to always be uppercase in the JSON */ ';
|
|
255
256
|
put ' options validvarname=upcase; ';
|
|
256
|
-
put '
|
|
257
|
+
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
|
258
|
+
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
|
259
|
+
put ' filename _sjs1 temp lrecl=200 ; ';
|
|
260
|
+
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
|
257
261
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
262
|
+
put ' run; ';
|
|
263
|
+
put ' /* now write to _webout 1 char at a time */ ';
|
|
264
|
+
put ' data _null_; ';
|
|
265
|
+
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
|
266
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
267
|
+
put ' input sourcechar $char1. @@; ';
|
|
268
|
+
put ' format sourcechar hex2.; ';
|
|
269
|
+
put ' put sourcechar char1. @@; ';
|
|
270
|
+
put ' run; ';
|
|
271
|
+
put ' filename _sjs1 clear; ';
|
|
258
272
|
put ' ';
|
|
259
273
|
put ' /* grab col defs */ ';
|
|
260
274
|
put ' proc contents noprint data=&ds ';
|
|
@@ -311,10 +325,20 @@ data _null_;
|
|
|
311
325
|
put ' data &tempds;set &ds; ';
|
|
312
326
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
313
327
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
314
|
-
put '
|
|
328
|
+
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
|
329
|
+
put ' proc json out=_sjs2 pretty ';
|
|
315
330
|
put ' %if &action=ARR %then nokeys ; ';
|
|
316
331
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
317
332
|
put ' run; ';
|
|
333
|
+
put ' /* send back to webout */ ';
|
|
334
|
+
put ' data _null_; ';
|
|
335
|
+
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
|
336
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
337
|
+
put ' input sourcechar $char1. @@; ';
|
|
338
|
+
put ' format sourcechar hex2.; ';
|
|
339
|
+
put ' put sourcechar char1. @@; ';
|
|
340
|
+
put ' run; ';
|
|
341
|
+
put ' filename _sjs2 clear; ';
|
|
318
342
|
put ' %end; ';
|
|
319
343
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
320
344
|
put ' %datastep: ';
|
|
@@ -397,10 +421,9 @@ data _null_;
|
|
|
397
421
|
put ' %end; ';
|
|
398
422
|
put ' run; ';
|
|
399
423
|
put ' ';
|
|
400
|
-
put '
|
|
401
|
-
put '
|
|
402
|
-
put '
|
|
403
|
-
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
424
|
+
put ' filename _sjs3 temp lrecl=131068 ; ';
|
|
425
|
+
put ' data _null_; ';
|
|
426
|
+
put ' file _sjs3 encoding=''utf-8''; ';
|
|
404
427
|
put ' if _n_=1 then put "["; ';
|
|
405
428
|
put ' set &tempds; ';
|
|
406
429
|
put ' if _n_>1 then put "," @; put ';
|
|
@@ -411,27 +434,29 @@ data _null_;
|
|
|
411
434
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
|
412
435
|
put ' %end; ';
|
|
413
436
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
414
|
-
put '
|
|
437
|
+
put ' ';
|
|
438
|
+
put ' /* close out the table */ ';
|
|
439
|
+
put ' data _null_; ';
|
|
440
|
+
put ' file _sjs3 mod encoding=''utf-8''; ';
|
|
441
|
+
put ' put '']''; ';
|
|
442
|
+
put ' run; ';
|
|
415
443
|
put ' data _null_; ';
|
|
416
|
-
put ' infile
|
|
444
|
+
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
|
417
445
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
418
446
|
put ' input sourcechar $char1. @@; ';
|
|
419
447
|
put ' format sourcechar hex2.; ';
|
|
420
448
|
put ' put sourcechar char1. @@; ';
|
|
421
449
|
put ' run; ';
|
|
422
|
-
put '
|
|
423
|
-
put ' data _null_; ';
|
|
424
|
-
put ' file &jref mod; ';
|
|
425
|
-
put ' put '']''; ';
|
|
426
|
-
put ' run; ';
|
|
427
|
-
put ' filename _sjs clear; ';
|
|
450
|
+
put ' filename _sjs3 clear; ';
|
|
428
451
|
put ' %end; ';
|
|
429
452
|
put ' ';
|
|
430
453
|
put ' proc sql; ';
|
|
431
454
|
put ' drop table &colinfo, &tempds; ';
|
|
432
455
|
put ' ';
|
|
433
456
|
put ' %if &showmeta=YES %then %do; ';
|
|
434
|
-
put '
|
|
457
|
+
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
|
458
|
+
put ' data _null_; ';
|
|
459
|
+
put ' file _sjs4; ';
|
|
435
460
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
|
436
461
|
put ' do i=1 to &numcols; ';
|
|
437
462
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
|
@@ -445,6 +470,15 @@ data _null_;
|
|
|
445
470
|
put ' end; ';
|
|
446
471
|
put ' put ''}}''; ';
|
|
447
472
|
put ' run; ';
|
|
473
|
+
put ' /* send back to webout */ ';
|
|
474
|
+
put ' data _null_; ';
|
|
475
|
+
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
|
476
|
+
put ' file &jref mod lrecl=1 recfm=n; ';
|
|
477
|
+
put ' input sourcechar $char1. @@; ';
|
|
478
|
+
put ' format sourcechar hex2.; ';
|
|
479
|
+
put ' put sourcechar char1. @@; ';
|
|
480
|
+
put ' run; ';
|
|
481
|
+
put ' filename _sjs4 clear; ';
|
|
448
482
|
put ' %end; ';
|
|
449
483
|
put '%end; ';
|
|
450
484
|
put ' ';
|