@sasjs/core 3.8.1 → 3.9.3
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_dirlist.sas +30 -9
- package/base/mp_jsonout.sas +114 -93
- package/base/mp_lockanytable.sas +1 -1
- package/meta/mm_createstp.sas +11 -8
- package/meta/mm_createwebservice.sas +136 -112
- package/meta/mm_webout.sas +14 -8
- package/package.json +2 -2
- package/server/ms_webout.sas +9 -7
- package/viya/mv_createwebservice.sas +122 -102
- package/viya/mv_webout.sas +14 -8
|
@@ -237,11 +237,15 @@ 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
|
|
240
|
+
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
|
|
241
|
+
put ' ,engine=DATASTEP ';
|
|
241
242
|
put ' ,dbg=0 /* DEPRECATED */ ';
|
|
242
243
|
put ' ,missing=NULL ';
|
|
244
|
+
put ' ,showmeta=NO ';
|
|
243
245
|
put ')/*/STORE SOURCE*/; ';
|
|
244
|
-
put '%
|
|
246
|
+
put '%local tempds colinfo fmtds i numcols; ';
|
|
247
|
+
put '%let numcols=0; ';
|
|
248
|
+
put ' ';
|
|
245
249
|
put '%if &action=OPEN %then %do; ';
|
|
246
250
|
put ' options nobomfile; ';
|
|
247
251
|
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
@@ -250,17 +254,61 @@ data _null_;
|
|
|
250
254
|
put '%end; ';
|
|
251
255
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
252
256
|
put ' options validvarname=upcase; ';
|
|
253
|
-
put ' data _null_;file &jref
|
|
257
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
|
254
258
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
255
259
|
put ' ';
|
|
260
|
+
put ' /* grab col defs */ ';
|
|
261
|
+
put ' proc contents noprint data=&ds ';
|
|
262
|
+
put ' out=_data_(keep=name type length format formatl formatd varnum label); ';
|
|
263
|
+
put ' run; ';
|
|
264
|
+
put ' %let colinfo=%scan(&syslast,2,.); ';
|
|
265
|
+
put ' proc sort data=&colinfo; ';
|
|
266
|
+
put ' by varnum; ';
|
|
267
|
+
put ' run; ';
|
|
268
|
+
put ' /* move meta to mac vars */ ';
|
|
269
|
+
put ' data _null_; ';
|
|
270
|
+
put ' if _n_=1 then call symputx(''numcols'',nobs,''l''); ';
|
|
271
|
+
put ' set &colinfo end=last nobs=nobs; ';
|
|
272
|
+
put ' name=upcase(name); ';
|
|
273
|
+
put ' /* fix formats */ ';
|
|
274
|
+
put ' if type=2 or type=6 then do; ';
|
|
275
|
+
put ' typelong=''char''; ';
|
|
276
|
+
put ' length fmt $49.; ';
|
|
277
|
+
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
|
278
|
+
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
279
|
+
put ' else fmt=cats(format,formatl,''.''); ';
|
|
280
|
+
put ' newlen=max(formatl,length); ';
|
|
281
|
+
put ' end; ';
|
|
282
|
+
put ' else do; ';
|
|
283
|
+
put ' typelong=''num''; ';
|
|
284
|
+
put ' if format='''' then fmt=''best.''; ';
|
|
285
|
+
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
286
|
+
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
|
287
|
+
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
|
288
|
+
put ' /* needs to be wide, for datetimes etc */ ';
|
|
289
|
+
put ' newlen=max(length,formatl,24); ';
|
|
290
|
+
put ' end; ';
|
|
291
|
+
put ' /* 32 char unique name */ ';
|
|
292
|
+
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
|
293
|
+
put ' ';
|
|
294
|
+
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
|
295
|
+
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
|
296
|
+
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
297
|
+
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
|
298
|
+
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
|
299
|
+
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
300
|
+
put ' call symputx(cats(''typelong'',_n_),typelong,''l''); ';
|
|
301
|
+
put ' call symputx(cats(''label'',_n_),coalescec(label,name),''l''); ';
|
|
302
|
+
put ' run; ';
|
|
303
|
+
put ' ';
|
|
304
|
+
put ' %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
|
|
305
|
+
put ' ';
|
|
256
306
|
put ' %if &engine=PROCJSON %then %do; ';
|
|
257
307
|
put ' %if &missing=STRING %then %do; ';
|
|
258
|
-
put ' %put &sysmacroname: Special Missings
|
|
308
|
+
put ' %put &sysmacroname: Special Missings not supported in proc json.; ';
|
|
259
309
|
put ' %put &sysmacroname: Switching to DATASTEP engine; ';
|
|
260
310
|
put ' %goto datastep; ';
|
|
261
311
|
put ' %end; ';
|
|
262
|
-
put ' data;run;%let tempds=&syslast; ';
|
|
263
|
-
put ' proc sql;drop table &tempds; ';
|
|
264
312
|
put ' data &tempds /view=&tempds;set &ds; ';
|
|
265
313
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
266
314
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
@@ -268,91 +316,35 @@ data _null_;
|
|
|
268
316
|
put ' %if &action=ARR %then nokeys ; ';
|
|
269
317
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
270
318
|
put ' run; ';
|
|
271
|
-
put ' proc sql;drop view &tempds; ';
|
|
272
319
|
put ' %end; ';
|
|
273
320
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
274
321
|
put ' %datastep: ';
|
|
275
|
-
put ' %
|
|
276
|
-
put ' %
|
|
277
|
-
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 %then %do; ';
|
|
322
|
+
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 ';
|
|
323
|
+
put ' %then %do; ';
|
|
278
324
|
put ' %put &sysmacroname: &ds NOT FOUND!!!; ';
|
|
279
325
|
put ' %return; ';
|
|
280
326
|
put ' %end; ';
|
|
281
|
-
put ' %if &fmt=Y %then %do; ';
|
|
282
|
-
put ' %put converting every variable to a formatted variable; ';
|
|
283
|
-
put ' /* see mp_ds2fmtds.sas for source */ ';
|
|
284
|
-
put ' proc contents noprint data=&ds ';
|
|
285
|
-
put ' out=_data_(keep=name type length format formatl formatd varnum); ';
|
|
286
|
-
put ' run; ';
|
|
287
|
-
put ' proc sort; ';
|
|
288
|
-
put ' by varnum; ';
|
|
289
|
-
put ' run; ';
|
|
290
|
-
put ' %local fmtds; ';
|
|
291
|
-
put ' %let fmtds=%scan(&syslast,2,.); ';
|
|
292
|
-
put ' /* prepare formats and varnames */ ';
|
|
293
|
-
put ' data _null_; ';
|
|
294
|
-
put ' if _n_=1 then call symputx(''nobs'',nobs,''l''); ';
|
|
295
|
-
put ' set &fmtds end=last nobs=nobs; ';
|
|
296
|
-
put ' name=upcase(name); ';
|
|
297
|
-
put ' /* fix formats */ ';
|
|
298
|
-
put ' if type=2 or type=6 then do; ';
|
|
299
|
-
put ' length fmt $49.; ';
|
|
300
|
-
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
|
301
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
302
|
-
put ' else fmt=cats(format,formatl,''.''); ';
|
|
303
|
-
put ' newlen=max(formatl,length); ';
|
|
304
|
-
put ' end; ';
|
|
305
|
-
put ' else do; ';
|
|
306
|
-
put ' if format='''' then fmt=''best.''; ';
|
|
307
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
308
|
-
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
|
309
|
-
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
|
310
|
-
put ' /* needs to be wide, for datetimes etc */ ';
|
|
311
|
-
put ' newlen=max(length,formatl,24); ';
|
|
312
|
-
put ' end; ';
|
|
313
|
-
put ' /* 32 char unique name */ ';
|
|
314
|
-
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
|
315
327
|
put ' ';
|
|
316
|
-
put '
|
|
317
|
-
put '
|
|
318
|
-
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
319
|
-
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
|
320
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
321
|
-
put ' run; ';
|
|
322
|
-
put ' data &fmtds; ';
|
|
328
|
+
put ' %if &fmt=Y %then %do; ';
|
|
329
|
+
put ' data _data_; ';
|
|
323
330
|
put ' /* rename on entry */ ';
|
|
324
331
|
put ' set &ds(rename=( ';
|
|
325
|
-
put ' %
|
|
326
|
-
put ' %do i=1 %to &nobs; ';
|
|
332
|
+
put ' %do i=1 %to &numcols; ';
|
|
327
333
|
put ' &&name&i=&&newname&i ';
|
|
328
334
|
put ' %end; ';
|
|
329
335
|
put ' )); ';
|
|
330
|
-
put ' %do i=1 %to &
|
|
336
|
+
put ' %do i=1 %to &numcols; ';
|
|
331
337
|
put ' length &&name&i $&&len&i; ';
|
|
332
338
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
|
333
339
|
put ' drop &&newname&i; ';
|
|
334
340
|
put ' %end; ';
|
|
335
341
|
put ' if _error_ then call symputx(''syscc'',1012); ';
|
|
336
342
|
put ' run; ';
|
|
337
|
-
put ' %let
|
|
338
|
-
put ' %end;
|
|
339
|
-
put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
|
|
340
|
-
put ' put "["; call symputx(''cols'',0,''l''); ';
|
|
341
|
-
put ' proc sort ';
|
|
342
|
-
put ' data=sashelp.vcolumn(where=(libname=''WORK'' & memname="%upcase(&ds)")) ';
|
|
343
|
-
put ' out=_data_; ';
|
|
344
|
-
put ' by varnum; ';
|
|
345
|
-
put ' ';
|
|
346
|
-
put ' data _null_; ';
|
|
347
|
-
put ' set _last_ end=last; ';
|
|
348
|
-
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
|
349
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
350
|
-
put ' call symputx(cats(''len'',_n_),length,''l''); ';
|
|
351
|
-
put ' if last then call symputx(''cols'',_n_,''l''); ';
|
|
352
|
-
put ' run; ';
|
|
343
|
+
put ' %let fmtds=&syslast; ';
|
|
344
|
+
put ' %end; ';
|
|
353
345
|
put ' ';
|
|
354
346
|
put ' proc format; /* credit yabwon for special null removal */ ';
|
|
355
|
-
put ' value bart ';
|
|
347
|
+
put ' value bart (default=40) ';
|
|
356
348
|
put ' %if &missing=NULL %then %do; ';
|
|
357
349
|
put ' ._ - .z = null ';
|
|
358
350
|
put ' %end; ';
|
|
@@ -363,20 +355,23 @@ data _null_;
|
|
|
363
355
|
put ' %end; ';
|
|
364
356
|
put ' other = [best.]; ';
|
|
365
357
|
put ' ';
|
|
366
|
-
put ' data;run; %let tempds=&syslast; /* temp table for spesh char management */ ';
|
|
367
|
-
put ' proc sql; drop table &tempds; ';
|
|
368
358
|
put ' data &tempds/view=&tempds; ';
|
|
369
359
|
put ' attrib _all_ label=''''; ';
|
|
370
|
-
put ' %do i=1 %to &
|
|
371
|
-
put ' %if &&
|
|
360
|
+
put ' %do i=1 %to &numcols; ';
|
|
361
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
372
362
|
put ' length &&name&i $32767; ';
|
|
373
363
|
put ' format &&name&i $32767.; ';
|
|
374
364
|
put ' %end; ';
|
|
375
365
|
put ' %end; ';
|
|
376
|
-
put '
|
|
366
|
+
put ' %if &fmt=Y %then %do; ';
|
|
367
|
+
put ' set &fmtds; ';
|
|
368
|
+
put ' %end; ';
|
|
369
|
+
put ' %else %do; ';
|
|
370
|
+
put ' set &ds; ';
|
|
371
|
+
put ' %end; ';
|
|
377
372
|
put ' format _numeric_ bart.; ';
|
|
378
|
-
put ' %do i=1 %to &
|
|
379
|
-
put ' %if &&
|
|
373
|
+
put ' %do i=1 %to &numcols; ';
|
|
374
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
380
375
|
put ' &&name&i=''"''!!trim(prxchange(''s/"/\"/'',-1, ';
|
|
381
376
|
put ' prxchange(''s/''!!''0A''x!!''/\n/'',-1, ';
|
|
382
377
|
put ' prxchange(''s/''!!''0D''x!!''/\r/'',-1, ';
|
|
@@ -386,49 +381,72 @@ data _null_;
|
|
|
386
381
|
put ' %end; ';
|
|
387
382
|
put ' %end; ';
|
|
388
383
|
put ' run; ';
|
|
384
|
+
put ' ';
|
|
389
385
|
put ' /* write to temp loc to avoid _webout truncation ';
|
|
390
386
|
put ' - https://support.sas.com/kb/49/325.html */ ';
|
|
391
387
|
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
|
392
388
|
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
389
|
+
put ' if _n_=1 then put "["; ';
|
|
393
390
|
put ' set &tempds; ';
|
|
394
391
|
put ' if _n_>1 then put "," @; put ';
|
|
395
392
|
put ' %if &action=ARR %then "[" ; %else "{" ; ';
|
|
396
|
-
put ' %do i=1 %to &
|
|
393
|
+
put ' %do i=1 %to &numcols; ';
|
|
397
394
|
put ' %if &i>1 %then "," ; ';
|
|
398
395
|
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
|
399
396
|
put ' &&name&i ';
|
|
400
397
|
put ' %end; ';
|
|
401
398
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
402
|
-
put ' proc sql; ';
|
|
403
|
-
put ' drop view &tempds; ';
|
|
404
399
|
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
|
405
400
|
put ' data _null_; ';
|
|
406
401
|
put ' length filein 8 fileid 8; ';
|
|
407
|
-
put ' filein
|
|
408
|
-
put ' fileid
|
|
409
|
-
put ' rec
|
|
402
|
+
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
403
|
+
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
404
|
+
put ' rec=''20''x; ';
|
|
410
405
|
put ' do while(fread(filein)=0); ';
|
|
411
|
-
put ' rc
|
|
412
|
-
put ' rc
|
|
413
|
-
put ' rc
|
|
406
|
+
put ' rc=fget(filein,rec,1); ';
|
|
407
|
+
put ' rc=fput(fileid, rec); ';
|
|
408
|
+
put ' rc=fwrite(fileid); ';
|
|
414
409
|
put ' end; ';
|
|
415
|
-
put '
|
|
416
|
-
put ' rc
|
|
410
|
+
put ' /* close out the table */ ';
|
|
411
|
+
put ' rc=fput(fileid, "]"); ';
|
|
412
|
+
put ' rc=fwrite(fileid); ';
|
|
413
|
+
put ' rc=fclose(filein); ';
|
|
414
|
+
put ' rc=fclose(fileid); ';
|
|
417
415
|
put ' run; ';
|
|
418
416
|
put ' filename _sjs clear; ';
|
|
419
|
-
put '
|
|
420
|
-
put '
|
|
417
|
+
put ' %end; ';
|
|
418
|
+
put ' ';
|
|
419
|
+
put ' proc sql; ';
|
|
420
|
+
put ' drop view &tempds; ';
|
|
421
|
+
put ' drop table &colinfo; ';
|
|
422
|
+
put ' ';
|
|
423
|
+
put ' %if &showmeta=YES %then %do; ';
|
|
424
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
|
425
|
+
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
|
426
|
+
put ' do i=1 to &numcols; ';
|
|
427
|
+
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
|
428
|
+
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
|
429
|
+
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
|
430
|
+
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
|
431
|
+
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
|
432
|
+
put ' if i>1 then put "," @@; ';
|
|
433
|
+
put ' put name '':{"format":'' format '',"label":'' label ';
|
|
434
|
+
put ' '',"length":'' length '',"type":'' type ''}''; ';
|
|
435
|
+
put ' end; ';
|
|
436
|
+
put ' put ''}}''; ';
|
|
421
437
|
put ' run; ';
|
|
422
438
|
put ' %end; ';
|
|
423
439
|
put '%end; ';
|
|
424
440
|
put ' ';
|
|
425
441
|
put '%else %if &action=CLOSE %then %do; ';
|
|
426
|
-
put ' data _null_;file &jref encoding=''utf-8'' mod ; ';
|
|
442
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod ; ';
|
|
427
443
|
put ' put "}"; ';
|
|
428
444
|
put ' run; ';
|
|
429
445
|
put '%end; ';
|
|
430
446
|
put '%mend mp_jsonout; ';
|
|
431
|
-
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL
|
|
447
|
+
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL ';
|
|
448
|
+
put ' ,showmeta=NO ';
|
|
449
|
+
put '); ';
|
|
432
450
|
put '%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name ';
|
|
433
451
|
put ' sasjs_tables SYS_JES_JOB_URI; ';
|
|
434
452
|
put '%if %index("&_debug",log) %then %let _debug=131; ';
|
|
@@ -550,12 +568,13 @@ data _null_;
|
|
|
550
568
|
put ' ';
|
|
551
569
|
put ' /* setup json */ ';
|
|
552
570
|
put ' data _null_;file &fref; ';
|
|
553
|
-
put ' put ''{"
|
|
571
|
+
put ' put ''{"SYSDATE" : "'' "&SYSDATE" ''"''; ';
|
|
572
|
+
put ' put '',"SYSTIME" : "'' "&SYSTIME" ''"''; ';
|
|
554
573
|
put ' run; ';
|
|
555
574
|
put '%end; ';
|
|
556
575
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
557
576
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
|
558
|
-
put ' ,jref=&fref,engine=DATASTEP,missing=&missing ';
|
|
577
|
+
put ' ,jref=&fref,engine=DATASTEP,missing=&missing,showmeta=&showmeta ';
|
|
559
578
|
put ' ) ';
|
|
560
579
|
put '%end; ';
|
|
561
580
|
put '%else %if &action=CLOSE %then %do; ';
|
|
@@ -575,9 +594,6 @@ data _null_;
|
|
|
575
594
|
put ' data _null_; file &fref mod; put ",""WORK"":{"; ';
|
|
576
595
|
put ' %do i=1 %to &wtcnt; ';
|
|
577
596
|
put ' %let wt=&&wt&i; ';
|
|
578
|
-
put ' proc contents noprint data=&wt ';
|
|
579
|
-
put ' out=_data_ (keep=name type length format:); ';
|
|
580
|
-
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
|
581
597
|
put ' data _null_; file &fref mod; ';
|
|
582
598
|
put ' dsid=open("WORK.&wt",''is''); ';
|
|
583
599
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
|
@@ -587,8 +603,7 @@ data _null_;
|
|
|
587
603
|
put ' put " ""&wt"" : {"; ';
|
|
588
604
|
put ' put ''"nlobs":'' nlobs; ';
|
|
589
605
|
put ' put '',"nvars":'' nvars; ';
|
|
590
|
-
put ' %mp_jsonout(OBJ,&
|
|
591
|
-
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP) ';
|
|
606
|
+
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
|
|
592
607
|
put ' data _null_; file &fref mod;put "}"; ';
|
|
593
608
|
put ' %end; ';
|
|
594
609
|
put ' data _null_; file &fref mod;put "}";run; ';
|
|
@@ -613,6 +628,9 @@ data _null_;
|
|
|
613
628
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
|
614
629
|
put ' put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; ';
|
|
615
630
|
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),datetime20.3)" ''" ''; ';
|
|
631
|
+
put ' memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)"; ';
|
|
632
|
+
put ' memsize=quote(cats(memsize)); ';
|
|
633
|
+
put ' put '',"MEMSIZE" : '' memsize; ';
|
|
616
634
|
put ' put "}"; ';
|
|
617
635
|
put ' ';
|
|
618
636
|
put ' %if %upcase(&fref) ne _WEBOUT and &stream=Y %then %do; ';
|
|
@@ -646,8 +664,10 @@ data _null_;
|
|
|
646
664
|
put '%global __program _program;';
|
|
647
665
|
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
|
648
666
|
put ' ';
|
|
649
|
-
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
|
650
|
-
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing
|
|
667
|
+
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
|
668
|
+
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
|
669
|
+
put ' ,showmeta=&showmeta';
|
|
670
|
+
put ' )';
|
|
651
671
|
put '%mend;';
|
|
652
672
|
run;
|
|
653
673
|
|
package/viya/mv_webout.sas
CHANGED
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
@param [in] stream=(Y) Change to N if not streaming to _webout
|
|
30
30
|
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
31
31
|
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
32
|
+
@param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
|
|
33
|
+
such as the column formats and types. The metadata is contained inside an
|
|
34
|
+
object with the same name as the table but prefixed with a dollar sign - ie,
|
|
35
|
+
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
32
36
|
|
|
33
37
|
<h4> SAS Macros </h4>
|
|
34
38
|
@li mp_jsonout.sas
|
|
@@ -38,7 +42,9 @@
|
|
|
38
42
|
@author Allan Bowe, source: https://github.com/sasjs/core
|
|
39
43
|
|
|
40
44
|
**/
|
|
41
|
-
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL
|
|
45
|
+
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL
|
|
46
|
+
,showmeta=NO
|
|
47
|
+
);
|
|
42
48
|
%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
|
|
43
49
|
sasjs_tables SYS_JES_JOB_URI;
|
|
44
50
|
%if %index("&_debug",log) %then %let _debug=131;
|
|
@@ -160,12 +166,13 @@
|
|
|
160
166
|
|
|
161
167
|
/* setup json */
|
|
162
168
|
data _null_;file &fref;
|
|
163
|
-
put '{"
|
|
169
|
+
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
170
|
+
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
164
171
|
run;
|
|
165
172
|
%end;
|
|
166
173
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
167
174
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
|
168
|
-
,jref=&fref,engine=DATASTEP,missing=&missing
|
|
175
|
+
,jref=&fref,engine=DATASTEP,missing=&missing,showmeta=&showmeta
|
|
169
176
|
)
|
|
170
177
|
%end;
|
|
171
178
|
%else %if &action=CLOSE %then %do;
|
|
@@ -185,9 +192,6 @@
|
|
|
185
192
|
data _null_; file &fref mod; put ",""WORK"":{";
|
|
186
193
|
%do i=1 %to &wtcnt;
|
|
187
194
|
%let wt=&&wt&i;
|
|
188
|
-
proc contents noprint data=&wt
|
|
189
|
-
out=_data_ (keep=name type length format:);
|
|
190
|
-
run;%let tempds=%scan(&syslast,2,.);
|
|
191
195
|
data _null_; file &fref mod;
|
|
192
196
|
dsid=open("WORK.&wt",'is');
|
|
193
197
|
nlobs=attrn(dsid,'NLOBS');
|
|
@@ -197,8 +201,7 @@
|
|
|
197
201
|
put " ""&wt"" : {";
|
|
198
202
|
put '"nlobs":' nlobs;
|
|
199
203
|
put ',"nvars":' nvars;
|
|
200
|
-
%mp_jsonout(OBJ,&
|
|
201
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
|
204
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
|
202
205
|
data _null_; file &fref mod;put "}";
|
|
203
206
|
%end;
|
|
204
207
|
data _null_; file &fref mod;put "}";run;
|
|
@@ -223,6 +226,9 @@
|
|
|
223
226
|
put ',"SYSVLONG" : ' sysvlong;
|
|
224
227
|
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
|
|
225
228
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
|
|
229
|
+
memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
|
|
230
|
+
memsize=quote(cats(memsize));
|
|
231
|
+
put ',"MEMSIZE" : ' memsize;
|
|
226
232
|
put "}";
|
|
227
233
|
|
|
228
234
|
%if %upcase(&fref) ne _WEBOUT and &stream=Y %then %do;
|