@sasjs/core 4.35.2 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/base/mp_jsonout.sas +5 -5
- package/meta/mm_createwebservice.sas +10 -8
- package/meta/mm_getstpinfo.sas +67 -0
- package/meta/mm_webout.sas +9 -4
- package/package.json +1 -1
- package/server/ms_createwebservice.sas +10 -8
- package/server/ms_webout.sas +9 -4
- package/viya/mv_createwebservice.sas +10 -8
- package/viya/mv_webout.sas +9 -4
package/README.md
CHANGED
|
@@ -36,21 +36,21 @@ Documentation: https://core.sasjs.io
|
|
|
36
36
|
- OS independent
|
|
37
37
|
- Works on all SAS Platforms
|
|
38
38
|
- No X command
|
|
39
|
-
- Prefixes:
|
|
39
|
+
- Prefixes: `mf_`, `mp_`
|
|
40
40
|
|
|
41
41
|
### DDL folder (All Platforms)
|
|
42
42
|
|
|
43
43
|
- OS independent
|
|
44
44
|
- Works on all SAS Platforms
|
|
45
45
|
- No X command
|
|
46
|
-
- Prefixes:
|
|
46
|
+
- Prefixes: `mddl_(lib)_` -> where lib can be "SAS" (in relation to a SAS component) or "DC" (in relation to a Data Controller component)
|
|
47
47
|
|
|
48
48
|
This library will not be used for storing data entries (such as formats or datalines). Where this becomes necessary in the future, a new repo will be created, in order to keep the NPM bundle size down (for the benefit of those looking to embed purely macros in their applications).
|
|
49
49
|
|
|
50
50
|
### FCMP folder (All Platforms)
|
|
51
51
|
|
|
52
52
|
- Function and macro names are identical, except for special cases
|
|
53
|
-
- Prefixes:
|
|
53
|
+
- Prefixes: `mcf_`
|
|
54
54
|
|
|
55
55
|
The fcmp macros are used to generate fcmp functions, and can be used with or without the `proc fcmp` wrapper.
|
|
56
56
|
|
|
@@ -72,7 +72,7 @@ endsubmit;
|
|
|
72
72
|
run;
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
- Prefixes:
|
|
75
|
+
- Prefixes: `ml_`
|
|
76
76
|
|
|
77
77
|
### META folder (SAS9 only)
|
|
78
78
|
|
|
@@ -81,14 +81,14 @@ Macros used in SAS EBI, which connect to the metadata server.
|
|
|
81
81
|
- OS independent
|
|
82
82
|
- Metadata aware
|
|
83
83
|
- No X command
|
|
84
|
-
- Prefixes:
|
|
84
|
+
- Prefixes: `mm_`
|
|
85
85
|
|
|
86
86
|
### METAX folder (SAS9 only)
|
|
87
87
|
|
|
88
88
|
- OS specific
|
|
89
89
|
- Metadata aware
|
|
90
90
|
- X command enabled
|
|
91
|
-
- Prefixes:
|
|
91
|
+
- Prefixes: `mmx_`
|
|
92
92
|
|
|
93
93
|
### SERVER folder (@sasjs/server only)
|
|
94
94
|
These macros are used for building applications using [@sasjs/server](https://server.sasjs.io) - an open source REST API for Desktop SAS.
|
|
@@ -96,7 +96,7 @@ These macros are used for building applications using [@sasjs/server](https://se
|
|
|
96
96
|
- OS independent
|
|
97
97
|
- @sasjs/server aware
|
|
98
98
|
- No X command
|
|
99
|
-
- Prefixes:
|
|
99
|
+
- Prefixes: `ms_`
|
|
100
100
|
|
|
101
101
|
### VIYA folder (Viya only)
|
|
102
102
|
|
|
@@ -104,7 +104,7 @@ Macros used for interfacing with SAS Viya.
|
|
|
104
104
|
|
|
105
105
|
- OS independent
|
|
106
106
|
- No X command
|
|
107
|
-
- Prefixes:
|
|
107
|
+
- Prefixes: `mv_`, `mvf_`
|
|
108
108
|
|
|
109
109
|
### XPLATFORM folder (Viya, Meta, and Server)
|
|
110
110
|
|
|
@@ -112,7 +112,7 @@ Sometimes it is helpful to use a macro that can be used interchangeably regardle
|
|
|
112
112
|
|
|
113
113
|
- OS independent
|
|
114
114
|
- No X command
|
|
115
|
-
- Prefixes:
|
|
115
|
+
- Prefixes: `mx_`
|
|
116
116
|
|
|
117
117
|
## Installation
|
|
118
118
|
|
package/base/mp_jsonout.sas
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
@param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
|
|
63
63
|
that should be converted to JSON
|
|
64
64
|
|
|
65
|
-
<h4> Related
|
|
65
|
+
<h4> Related Files </h4>
|
|
66
66
|
@li mp_ds2fmtds.sas
|
|
67
67
|
|
|
68
68
|
@version 9.2
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
order by 1;
|
|
211
211
|
create table &tmpds2(
|
|
212
212
|
FMTNAME char(32),
|
|
213
|
-
|
|
213
|
+
LENGTH num
|
|
214
214
|
);
|
|
215
215
|
%local catlist cat fmtlist i;
|
|
216
216
|
select distinct fmtcat into: catlist separated by ' ' from &tmpds1;
|
|
@@ -219,16 +219,16 @@
|
|
|
219
219
|
proc sql;
|
|
220
220
|
select distinct fmtname into: fmtlist separated by ' '
|
|
221
221
|
from &tmpds1 where fmtcat="&cat";
|
|
222
|
-
proc format lib=&cat cntlout=&tmpds3(keep=fmtname
|
|
222
|
+
proc format lib=&cat cntlout=&tmpds3(keep=fmtname length);
|
|
223
223
|
select &fmtlist;
|
|
224
224
|
run;
|
|
225
225
|
proc sql;
|
|
226
|
-
insert into &tmpds2 select distinct fmtname,
|
|
226
|
+
insert into &tmpds2 select distinct fmtname,length from &tmpds3;
|
|
227
227
|
%end;
|
|
228
228
|
|
|
229
229
|
proc sql;
|
|
230
230
|
create table &tmpds4 as
|
|
231
|
-
select a.*, b.
|
|
231
|
+
select a.*, b.length as maxw
|
|
232
232
|
from &colinfo a
|
|
233
233
|
left join &tmpds2 b
|
|
234
234
|
on cats(a.format)=cats(upcase(b.fmtname))
|
|
@@ -233,7 +233,7 @@ data _null_;
|
|
|
233
233
|
put ' order by 1; ';
|
|
234
234
|
put ' create table &tmpds2( ';
|
|
235
235
|
put ' FMTNAME char(32), ';
|
|
236
|
-
put '
|
|
236
|
+
put ' LENGTH num ';
|
|
237
237
|
put ' ); ';
|
|
238
238
|
put ' %local catlist cat fmtlist i; ';
|
|
239
239
|
put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
|
|
@@ -242,16 +242,16 @@ data _null_;
|
|
|
242
242
|
put ' proc sql; ';
|
|
243
243
|
put ' select distinct fmtname into: fmtlist separated by '' '' ';
|
|
244
244
|
put ' from &tmpds1 where fmtcat="&cat"; ';
|
|
245
|
-
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname
|
|
245
|
+
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
|
|
246
246
|
put ' select &fmtlist; ';
|
|
247
247
|
put ' run; ';
|
|
248
248
|
put ' proc sql; ';
|
|
249
|
-
put ' insert into &tmpds2 select distinct fmtname,
|
|
249
|
+
put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
|
|
250
250
|
put ' %end; ';
|
|
251
251
|
put ' ';
|
|
252
252
|
put ' proc sql; ';
|
|
253
253
|
put ' create table &tmpds4 as ';
|
|
254
|
-
put ' select a.*, b.
|
|
254
|
+
put ' select a.*, b.length as maxw ';
|
|
255
255
|
put ' from &colinfo a ';
|
|
256
256
|
put ' left join &tmpds2 b ';
|
|
257
257
|
put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
|
|
@@ -447,7 +447,7 @@ data _null_;
|
|
|
447
447
|
put ' ';
|
|
448
448
|
put '%mend mf_getuser; ';
|
|
449
449
|
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL ';
|
|
450
|
-
put ' ,showmeta=N,maxobs=MAX ';
|
|
450
|
+
put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
|
|
451
451
|
put '); ';
|
|
452
452
|
put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
|
|
453
453
|
put ' sasjs_tables; ';
|
|
@@ -520,8 +520,8 @@ data _null_;
|
|
|
520
520
|
put '%else %if &action=CLOSE %then %do; ';
|
|
521
521
|
put ' /* To avoid issues with _webout on EBI we use a temporary file */ ';
|
|
522
522
|
put ' filename _sjsref temp lrecl=131068; ';
|
|
523
|
-
put ' %if %str(&
|
|
524
|
-
put ' /* if debug mode, send back first
|
|
523
|
+
put ' %if %str(&workobs) > 0 %then %do; ';
|
|
524
|
+
put ' /* if debug mode, send back first XX records of each work table also */ ';
|
|
525
525
|
put ' data;run;%let tempds=%scan(&syslast,2,.); ';
|
|
526
526
|
put ' ods output Members=&tempds; ';
|
|
527
527
|
put ' proc datasets library=WORK memtype=data; ';
|
|
@@ -545,7 +545,9 @@ data _null_;
|
|
|
545
545
|
put ' put " ""&wt"" : {"; ';
|
|
546
546
|
put ' put ''"nlobs":'' nlobs; ';
|
|
547
547
|
put ' put '',"nvars":'' nvars; ';
|
|
548
|
-
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
548
|
+
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 ';
|
|
549
|
+
put ' ,maxobs=&workobs ';
|
|
550
|
+
put ' ) ';
|
|
549
551
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
|
550
552
|
put ' put "}"; ';
|
|
551
553
|
put ' %end; ';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Get the properties of a Stored Process
|
|
4
|
+
@details Extracts various properties and creates an output table in the
|
|
5
|
+
structure below:
|
|
6
|
+
|
|
7
|
+
|STP_URI:$200.|SERVERCONTEXT:$200.|STOREDPROCESSCONFIGURATION:$1000.|SOURCECODE_FIRST32K:$32767.|PATH:$76.|
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
|`A5DN9TDQ.BH0000C8 `|`SASApp `|`<?xml version="1.0" encoding="UTF-8"?><StoredProcess><ServerContext LogicalServerType="Sps" OtherAllowed="false"/><ResultCapabilities Package="false" Streaming="true"/><OutputParameters/></StoredProcess> `|`%put first 32767 bytes of code; `|`/path/to/my/stp`|
|
|
10
|
+
|
|
11
|
+
@param [in] pgm The metadata path of the Stored Process
|
|
12
|
+
@param [out] outds= (work.mm_getstpinfo) The output table to create
|
|
13
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
14
|
+
|
|
15
|
+
<h4> Related Files </h4>
|
|
16
|
+
@li mm_getstpcode.sas
|
|
17
|
+
@li mm_getstps.sas
|
|
18
|
+
@li mm_createstp.sas
|
|
19
|
+
@li mm_deletestp.sas
|
|
20
|
+
|
|
21
|
+
**/
|
|
22
|
+
|
|
23
|
+
%macro mm_getstpinfo(pgm
|
|
24
|
+
,outds=work.mm_getstpinfo
|
|
25
|
+
,mDebug=0
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
%local mD;
|
|
29
|
+
%if &mDebug=1 %then %let mD=;
|
|
30
|
+
%else %let mD=%str(*);
|
|
31
|
+
%&mD.put Executing &sysmacroname..sas;
|
|
32
|
+
%&mD.put _local_;
|
|
33
|
+
|
|
34
|
+
data &outds;
|
|
35
|
+
length type stp_uri tsuri servercontext value $200
|
|
36
|
+
StoredProcessConfiguration $1000 sourcecode_first32k $32767;
|
|
37
|
+
keep path stp_uri sourcecode_first32k StoredProcessConfiguration
|
|
38
|
+
servercontext;
|
|
39
|
+
call missing (of _all_);
|
|
40
|
+
path="&pgm(StoredProcess)";
|
|
41
|
+
/* first, find the STP ID */
|
|
42
|
+
if metadata_pathobj("",path,"StoredProcess",type,stp_uri)>0 then do;
|
|
43
|
+
/* get attributes */
|
|
44
|
+
cnt=1;
|
|
45
|
+
do while (metadata_getnasn(stp_uri,"Notes",cnt,tsuri)>0);
|
|
46
|
+
rc1=metadata_getattr(tsuri,"Name",value);
|
|
47
|
+
&mD.put tsuri= value=;
|
|
48
|
+
if value="SourceCode" then do;
|
|
49
|
+
rc2=metadata_getattr(tsuri,"StoredText",sourcecode_first32k);
|
|
50
|
+
end;
|
|
51
|
+
else if value="Stored Process" then do;
|
|
52
|
+
rc3=metadata_getattr(tsuri,"StoredText",StoredProcessConfiguration);
|
|
53
|
+
end;
|
|
54
|
+
cnt+1;
|
|
55
|
+
end;
|
|
56
|
+
/* get context (should only be one) */
|
|
57
|
+
rc4=metadata_getnasn(stp_uri,"ComputeLocations",1,tsuri);
|
|
58
|
+
rc5=metadata_getattr(tsuri,"Name",servercontext);
|
|
59
|
+
end;
|
|
60
|
+
else do;
|
|
61
|
+
put "%str(ERR)OR: could not find " pgm;
|
|
62
|
+
put (_all_)(=);
|
|
63
|
+
end;
|
|
64
|
+
&md.put (_all_)(=);
|
|
65
|
+
run;
|
|
66
|
+
|
|
67
|
+
%mend mm_getstpinfo ;
|
package/meta/mm_webout.sas
CHANGED
|
@@ -34,6 +34,9 @@
|
|
|
34
34
|
such as the column formats and types. The metadata is contained inside an
|
|
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
|
+
@param [in] workobs= (0) When set to a positive integer, will create a new
|
|
38
|
+
output object (WORK) which contains this number of observations from all
|
|
39
|
+
tables in the WORK library.
|
|
37
40
|
@param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
|
|
38
41
|
that should be converted to output JSON
|
|
39
42
|
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
|
|
50
53
|
**/
|
|
51
54
|
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL
|
|
52
|
-
,showmeta=N,maxobs=MAX
|
|
55
|
+
,showmeta=N,maxobs=MAX,workobs=0
|
|
53
56
|
);
|
|
54
57
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
55
58
|
sasjs_tables;
|
|
@@ -122,8 +125,8 @@
|
|
|
122
125
|
%else %if &action=CLOSE %then %do;
|
|
123
126
|
/* To avoid issues with _webout on EBI we use a temporary file */
|
|
124
127
|
filename _sjsref temp lrecl=131068;
|
|
125
|
-
%if %str(&
|
|
126
|
-
/* if debug mode, send back first
|
|
128
|
+
%if %str(&workobs) > 0 %then %do;
|
|
129
|
+
/* if debug mode, send back first XX records of each work table also */
|
|
127
130
|
data;run;%let tempds=%scan(&syslast,2,.);
|
|
128
131
|
ods output Members=&tempds;
|
|
129
132
|
proc datasets library=WORK memtype=data;
|
|
@@ -147,7 +150,9 @@
|
|
|
147
150
|
put " ""&wt"" : {";
|
|
148
151
|
put '"nlobs":' nlobs;
|
|
149
152
|
put ',"nvars":' nvars;
|
|
150
|
-
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
153
|
+
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
154
|
+
,maxobs=&workobs
|
|
155
|
+
)
|
|
151
156
|
data _null_; file _sjsref mod encoding='utf-8';
|
|
152
157
|
put "}";
|
|
153
158
|
%end;
|
package/package.json
CHANGED
|
@@ -234,7 +234,7 @@ data _null_;
|
|
|
234
234
|
put ' order by 1; ';
|
|
235
235
|
put ' create table &tmpds2( ';
|
|
236
236
|
put ' FMTNAME char(32), ';
|
|
237
|
-
put '
|
|
237
|
+
put ' LENGTH num ';
|
|
238
238
|
put ' ); ';
|
|
239
239
|
put ' %local catlist cat fmtlist i; ';
|
|
240
240
|
put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
|
|
@@ -243,16 +243,16 @@ data _null_;
|
|
|
243
243
|
put ' proc sql; ';
|
|
244
244
|
put ' select distinct fmtname into: fmtlist separated by '' '' ';
|
|
245
245
|
put ' from &tmpds1 where fmtcat="&cat"; ';
|
|
246
|
-
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname
|
|
246
|
+
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
|
|
247
247
|
put ' select &fmtlist; ';
|
|
248
248
|
put ' run; ';
|
|
249
249
|
put ' proc sql; ';
|
|
250
|
-
put ' insert into &tmpds2 select distinct fmtname,
|
|
250
|
+
put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
|
|
251
251
|
put ' %end; ';
|
|
252
252
|
put ' ';
|
|
253
253
|
put ' proc sql; ';
|
|
254
254
|
put ' create table &tmpds4 as ';
|
|
255
|
-
put ' select a.*, b.
|
|
255
|
+
put ' select a.*, b.length as maxw ';
|
|
256
256
|
put ' from &colinfo a ';
|
|
257
257
|
put ' left join &tmpds2 b ';
|
|
258
258
|
put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
|
|
@@ -449,7 +449,7 @@ data _null_;
|
|
|
449
449
|
put '%mend mf_getuser; ';
|
|
450
450
|
put ' ';
|
|
451
451
|
put '%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL ';
|
|
452
|
-
put ' ,showmeta=N,maxobs=MAX ';
|
|
452
|
+
put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
|
|
453
453
|
put '); ';
|
|
454
454
|
put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
|
|
455
455
|
put ' sasjs_tables; ';
|
|
@@ -512,8 +512,8 @@ data _null_;
|
|
|
512
512
|
put ' ) ';
|
|
513
513
|
put '%end; ';
|
|
514
514
|
put '%else %if &action=CLOSE %then %do; ';
|
|
515
|
-
put ' %if %str(&
|
|
516
|
-
put ' /* if debug mode, send back first
|
|
515
|
+
put ' %if %str(&workobs) > 0 %then %do; ';
|
|
516
|
+
put ' /* if debug mode, send back first XX records of each work table also */ ';
|
|
517
517
|
put ' data;run;%let tempds=%scan(&syslast,2,.); ';
|
|
518
518
|
put ' ods output Members=&tempds; ';
|
|
519
519
|
put ' proc datasets library=WORK memtype=data; ';
|
|
@@ -538,7 +538,9 @@ data _null_;
|
|
|
538
538
|
put ' put " ""&wt"" : {"; ';
|
|
539
539
|
put ' put ''"nlobs":'' nlobs; ';
|
|
540
540
|
put ' put '',"nvars":'' nvars; ';
|
|
541
|
-
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
541
|
+
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 ';
|
|
542
|
+
put ' ,maxobs=&workobs ';
|
|
543
|
+
put ' ) ';
|
|
542
544
|
put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
|
|
543
545
|
put ' put "}"; ';
|
|
544
546
|
put ' %end; ';
|
package/server/ms_webout.sas
CHANGED
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
such as the column formats and types. The metadata is contained inside an
|
|
32
32
|
object with the same name as the table but prefixed with a dollar sign - ie,
|
|
33
33
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
34
|
+
@param [in] workobs= (0) When set to a positive integer, will create a new
|
|
35
|
+
output object (WORK) which contains this number of observations from all
|
|
36
|
+
tables in the WORK library.
|
|
34
37
|
@param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
|
|
35
38
|
that should be converted to output JSON
|
|
36
39
|
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
**/
|
|
50
53
|
|
|
51
54
|
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL
|
|
52
|
-
,showmeta=N,maxobs=MAX
|
|
55
|
+
,showmeta=N,maxobs=MAX,workobs=0
|
|
53
56
|
);
|
|
54
57
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
55
58
|
sasjs_tables;
|
|
@@ -112,8 +115,8 @@
|
|
|
112
115
|
)
|
|
113
116
|
%end;
|
|
114
117
|
%else %if &action=CLOSE %then %do;
|
|
115
|
-
%if %str(&
|
|
116
|
-
/* if debug mode, send back first
|
|
118
|
+
%if %str(&workobs) > 0 %then %do;
|
|
119
|
+
/* if debug mode, send back first XX records of each work table also */
|
|
117
120
|
data;run;%let tempds=%scan(&syslast,2,.);
|
|
118
121
|
ods output Members=&tempds;
|
|
119
122
|
proc datasets library=WORK memtype=data;
|
|
@@ -138,7 +141,9 @@
|
|
|
138
141
|
put " ""&wt"" : {";
|
|
139
142
|
put '"nlobs":' nlobs;
|
|
140
143
|
put ',"nvars":' nvars;
|
|
141
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
144
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10
|
|
145
|
+
,maxobs=&workobs
|
|
146
|
+
)
|
|
142
147
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
143
148
|
put "}";
|
|
144
149
|
%end;
|
|
@@ -376,7 +376,7 @@ data _null_;
|
|
|
376
376
|
put ' order by 1; ';
|
|
377
377
|
put ' create table &tmpds2( ';
|
|
378
378
|
put ' FMTNAME char(32), ';
|
|
379
|
-
put '
|
|
379
|
+
put ' LENGTH num ';
|
|
380
380
|
put ' ); ';
|
|
381
381
|
put ' %local catlist cat fmtlist i; ';
|
|
382
382
|
put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
|
|
@@ -385,16 +385,16 @@ data _null_;
|
|
|
385
385
|
put ' proc sql; ';
|
|
386
386
|
put ' select distinct fmtname into: fmtlist separated by '' '' ';
|
|
387
387
|
put ' from &tmpds1 where fmtcat="&cat"; ';
|
|
388
|
-
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname
|
|
388
|
+
put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
|
|
389
389
|
put ' select &fmtlist; ';
|
|
390
390
|
put ' run; ';
|
|
391
391
|
put ' proc sql; ';
|
|
392
|
-
put ' insert into &tmpds2 select distinct fmtname,
|
|
392
|
+
put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
|
|
393
393
|
put ' %end; ';
|
|
394
394
|
put ' ';
|
|
395
395
|
put ' proc sql; ';
|
|
396
396
|
put ' create table &tmpds4 as ';
|
|
397
|
-
put ' select a.*, b.
|
|
397
|
+
put ' select a.*, b.length as maxw ';
|
|
398
398
|
put ' from &colinfo a ';
|
|
399
399
|
put ' left join &tmpds2 b ';
|
|
400
400
|
put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
|
|
@@ -590,7 +590,7 @@ data _null_;
|
|
|
590
590
|
put ' ';
|
|
591
591
|
put '%mend mf_getuser; ';
|
|
592
592
|
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=N,stream=Y,missing=NULL ';
|
|
593
|
-
put ' ,showmeta=N,maxobs=MAX ';
|
|
593
|
+
put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
|
|
594
594
|
put '); ';
|
|
595
595
|
put '%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name ';
|
|
596
596
|
put ' sasjs_tables SYS_JES_JOB_URI; ';
|
|
@@ -697,8 +697,8 @@ data _null_;
|
|
|
697
697
|
put ' ) ';
|
|
698
698
|
put '%end; ';
|
|
699
699
|
put '%else %if &action=CLOSE %then %do; ';
|
|
700
|
-
put ' %if %str(&
|
|
701
|
-
put ' /* send back first
|
|
700
|
+
put ' %if %str(&workobs) > 0 %then %do; ';
|
|
701
|
+
put ' /* send back first XX records of each work table for debugging */ ';
|
|
702
702
|
put ' data;run;%let tempds=%scan(&syslast,2,.); ';
|
|
703
703
|
put ' ods output Members=&tempds; ';
|
|
704
704
|
put ' proc datasets library=WORK memtype=data; ';
|
|
@@ -721,7 +721,9 @@ data _null_;
|
|
|
721
721
|
put ' put " ""&wt"" : {"; ';
|
|
722
722
|
put ' put ''"nlobs":'' nlobs; ';
|
|
723
723
|
put ' put '',"nvars":'' nvars; ';
|
|
724
|
-
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
|
|
724
|
+
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y ';
|
|
725
|
+
put ' ,maxobs=&workobs ';
|
|
726
|
+
put ' ) ';
|
|
725
727
|
put ' data _null_; file &fref mod;put "}"; ';
|
|
726
728
|
put ' %end; ';
|
|
727
729
|
put ' data _null_; file &fref mod;put "}";run; ';
|
package/viya/mv_webout.sas
CHANGED
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
36
36
|
@param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
|
|
37
37
|
that should be converted to output JSON
|
|
38
|
+
@param [in] workobs= (0) When set to a positive integer, will create a new
|
|
39
|
+
output object (WORK) which contains this number of observations from all
|
|
40
|
+
tables in the WORK library.
|
|
38
41
|
|
|
39
42
|
<h4> SAS Macros </h4>
|
|
40
43
|
@li mp_jsonout.sas
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
|
|
50
53
|
**/
|
|
51
54
|
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=N,stream=Y,missing=NULL
|
|
52
|
-
,showmeta=N,maxobs=MAX
|
|
55
|
+
,showmeta=N,maxobs=MAX,workobs=0
|
|
53
56
|
);
|
|
54
57
|
%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
|
|
55
58
|
sasjs_tables SYS_JES_JOB_URI;
|
|
@@ -156,8 +159,8 @@
|
|
|
156
159
|
)
|
|
157
160
|
%end;
|
|
158
161
|
%else %if &action=CLOSE %then %do;
|
|
159
|
-
%if %str(&
|
|
160
|
-
/* send back first
|
|
162
|
+
%if %str(&workobs) > 0 %then %do;
|
|
163
|
+
/* send back first XX records of each work table for debugging */
|
|
161
164
|
data;run;%let tempds=%scan(&syslast,2,.);
|
|
162
165
|
ods output Members=&tempds;
|
|
163
166
|
proc datasets library=WORK memtype=data;
|
|
@@ -180,7 +183,9 @@
|
|
|
180
183
|
put " ""&wt"" : {";
|
|
181
184
|
put '"nlobs":' nlobs;
|
|
182
185
|
put ',"nvars":' nvars;
|
|
183
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
|
|
186
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
|
|
187
|
+
,maxobs=&workobs
|
|
188
|
+
)
|
|
184
189
|
data _null_; file &fref mod;put "}";
|
|
185
190
|
%end;
|
|
186
191
|
data _null_; file &fref mod;put "}";run;
|