@sasjs/core 4.35.0 → 4.35.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.
@@ -70,14 +70,14 @@
70
70
  @source https://github.com/sasjs/core
71
71
 
72
72
  **/
73
-
74
73
  %macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y
75
74
  ,engine=DATASTEP
76
75
  ,missing=NULL
77
76
  ,showmeta=N
78
77
  ,maxobs=MAX
79
78
  )/*/STORE SOURCE*/;
80
- %local tempds colinfo fmtds i numcols stmt_obs;
79
+ %local tempds colinfo fmtds i numcols numobs stmt_obs lastobs optval
80
+ tmpds1 tmpds2 tmpds3 tmpds4;
81
81
  %let numcols=0;
82
82
  %if &maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;);
83
83
 
@@ -115,7 +115,7 @@
115
115
  by varnum;
116
116
  run;
117
117
  /* move meta to mac vars */
118
- data _null_;
118
+ data &colinfo;
119
119
  if _n_=1 then call symputx('numcols',nobs,'l');
120
120
  set &colinfo end=last nobs=nobs;
121
121
  name=upcase(name);
@@ -144,9 +144,15 @@
144
144
  call symputx(cats('type',_n_),type,'l');
145
145
  call symputx(cats('typelong',_n_),typelong,'l');
146
146
  call symputx(cats('label',_n_),coalescec(label,name),'l');
147
+ /* overwritten when fmt=Y and a custom format exists in catalog */
148
+ if typelong='num' then call symputx(cats('fmtlen',_n_),200,'l');
149
+ else call symputx(cats('fmtlen',_n_),min(32767,ceil((length+3)*1.5)),'l');
147
150
  run;
148
151
 
149
152
  %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32);
153
+ proc sql;
154
+ select count(*) into: lastobs from &ds;
155
+ %if &maxobs ne MAX %then %let lastobs=%sysfunc(min(&lastobs,&maxobs));
150
156
 
151
157
  %if &engine=PROCJSON %then %do;
152
158
  %if &missing=STRING %then %do;
@@ -183,27 +189,99 @@
183
189
  %end;
184
190
 
185
191
  %if &fmt=Y %then %do;
186
- data _data_;
192
+ /**
193
+ * Extract format definitions
194
+ * First, by getting library locations from dictionary.formats
195
+ * Then, by exporting the width using proc format
196
+ * Cannot use maxw from sashelp.vformat as not always populated
197
+ * Cannot use fmtinfo() as not supported in all flavours
198
+ */
199
+ %let tmpds1=%substr(fmtsum%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32);
200
+ %let tmpds2=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32);
201
+ %let tmpds3=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32);
202
+ %let tmpds4=%substr(col%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32);
203
+ proc sql noprint;
204
+ create table &tmpds1 as
205
+ select cats(libname,'.',memname) as fmtcat,
206
+ fmtname
207
+ from dictionary.formats
208
+ where fmttype='F' and libname is not null
209
+ and fmtname in (select format from &colinfo where format is not null)
210
+ order by 1;
211
+ create table &tmpds2(
212
+ FMTNAME char(32),
213
+ MAX num length=3
214
+ );
215
+ %local catlist cat fmtlist i;
216
+ select distinct fmtcat into: catlist separated by ' ' from &tmpds1;
217
+ %do i=1 %to %sysfunc(countw(&catlist,%str( )));
218
+ %let cat=%scan(&catlist,&i,%str( ));
219
+ proc sql;
220
+ select distinct fmtname into: fmtlist separated by ' '
221
+ from &tmpds1 where fmtcat="&cat";
222
+ proc format lib=&cat cntlout=&tmpds3(keep=fmtname max);
223
+ select &fmtlist;
224
+ run;
225
+ proc sql;
226
+ insert into &tmpds2 select distinct fmtname,max from &tmpds3;
227
+ %end;
228
+
229
+ proc sql;
230
+ create table &tmpds4 as
231
+ select a.*, b.max as maxw
232
+ from &colinfo a
233
+ left join &tmpds2 b
234
+ on cats(a.format)=cats(upcase(b.fmtname))
235
+ order by a.varnum;
236
+ data _null_;
237
+ set &tmpds4;
238
+ if not missing(maxw);
239
+ call symputx(
240
+ cats('fmtlen',_n_),
241
+ /* vars need extra padding due to JSON escaping of special chars */
242
+ min(32767,ceil((max(length,maxw)+3)*1.5))
243
+ ,'l'
244
+ );
245
+ run;
246
+
247
+ /* configure varlenchk - as we are explicitly shortening the variables */
248
+ %let optval=%sysfunc(getoption(varlenchk));
249
+ options varlenchk=NOWARN;
250
+ data _data_(compress=char);
251
+ /* shorten the new vars */
252
+ length
253
+ %do i=1 %to &numcols;
254
+ &&name&i $&&fmtlen&i
255
+ %end;
256
+ ;
187
257
  /* rename on entry */
188
258
  set &ds(rename=(
189
259
  %do i=1 %to &numcols;
190
- &&name&i=&&newname&i
260
+ &&name&i=&&newname&i
191
261
  %end;
192
262
  ));
263
+ &stmt_obs;
264
+
265
+ drop
266
+ %do i=1 %to &numcols;
267
+ &&newname&i
268
+ %end;
269
+ ;
193
270
  %do i=1 %to &numcols;
194
- /* formatted values can be up to length 32767 */
195
- length &&name&i $32767;
196
271
  %if &&typelong&i=num %then %do;
197
- &&name&i=left(put(&&newname&i,&&fmt&i));
272
+ &&name&i=cats(put(&&newname&i,&&fmt&i));
198
273
  %end;
199
274
  %else %do;
200
275
  &&name&i=put(&&newname&i,&&fmt&i);
201
276
  %end;
202
- drop &&newname&i;
203
277
  %end;
204
- if _error_ then call symputx('syscc',1012);
278
+ if _error_ then do;
279
+ call symputx('syscc',1012);
280
+ stop;
281
+ end;
205
282
  run;
206
283
  %let fmtds=&syslast;
284
+ options varlenchk=&optval;
207
285
  %end;
208
286
 
209
287
  proc format; /* credit yabwon for special null removal */
@@ -222,8 +300,8 @@
222
300
  attrib _all_ label='';
223
301
  %do i=1 %to &numcols;
224
302
  %if &&typelong&i=char or &fmt=Y %then %do;
225
- length &&name&i $32767;
226
- format &&name&i $32767.;
303
+ length &&name&i $&&fmtlen&i...;
304
+ format &&name&i $&&fmtlen&i...;
227
305
  %end;
228
306
  %end;
229
307
  %if &fmt=Y %then %do;
@@ -93,14 +93,14 @@ data _null_;
93
93
  file sasjs lrecl=3000 ;
94
94
  put "/* Created on %sysfunc(datetime(),datetime19.) by %mf_getuser() */";
95
95
  /* WEBOUT BEGIN */
96
- put ' ';
97
96
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
98
97
  put ' ,engine=DATASTEP ';
99
98
  put ' ,missing=NULL ';
100
99
  put ' ,showmeta=N ';
101
100
  put ' ,maxobs=MAX ';
102
101
  put ')/*/STORE SOURCE*/; ';
103
- put '%local tempds colinfo fmtds i numcols stmt_obs; ';
102
+ put '%local tempds colinfo fmtds i numcols numobs stmt_obs lastobs optval ';
103
+ put ' tmpds1 tmpds2 tmpds3 tmpds4; ';
104
104
  put '%let numcols=0; ';
105
105
  put '%if &maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
106
106
  put ' ';
@@ -138,7 +138,7 @@ data _null_;
138
138
  put ' by varnum; ';
139
139
  put ' run; ';
140
140
  put ' /* move meta to mac vars */ ';
141
- put ' data _null_; ';
141
+ put ' data &colinfo; ';
142
142
  put ' if _n_=1 then call symputx(''numcols'',nobs,''l''); ';
143
143
  put ' set &colinfo end=last nobs=nobs; ';
144
144
  put ' name=upcase(name); ';
@@ -167,9 +167,15 @@ data _null_;
167
167
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
168
168
  put ' call symputx(cats(''typelong'',_n_),typelong,''l''); ';
169
169
  put ' call symputx(cats(''label'',_n_),coalescec(label,name),''l''); ';
170
+ put ' /* overwritten when fmt=Y and a custom format exists in catalog */ ';
171
+ put ' if typelong=''num'' then call symputx(cats(''fmtlen'',_n_),200,''l''); ';
172
+ put ' else call symputx(cats(''fmtlen'',_n_),min(32767,ceil((length+3)*1.5)),''l''); ';
170
173
  put ' run; ';
171
174
  put ' ';
172
175
  put ' %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
176
+ put ' proc sql; ';
177
+ put ' select count(*) into: lastobs from &ds; ';
178
+ put ' %if &maxobs ne MAX %then %let lastobs=%sysfunc(min(&lastobs,&maxobs)); ';
173
179
  put ' ';
174
180
  put ' %if &engine=PROCJSON %then %do; ';
175
181
  put ' %if &missing=STRING %then %do; ';
@@ -206,27 +212,99 @@ data _null_;
206
212
  put ' %end; ';
207
213
  put ' ';
208
214
  put ' %if &fmt=Y %then %do; ';
209
- put ' data _data_; ';
215
+ put ' /** ';
216
+ put ' * Extract format definitions ';
217
+ put ' * First, by getting library locations from dictionary.formats ';
218
+ put ' * Then, by exporting the width using proc format ';
219
+ put ' * Cannot use maxw from sashelp.vformat as not always populated ';
220
+ put ' * Cannot use fmtinfo() as not supported in all flavours ';
221
+ put ' */ ';
222
+ put ' %let tmpds1=%substr(fmtsum%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
223
+ put ' %let tmpds2=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
224
+ put ' %let tmpds3=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
225
+ put ' %let tmpds4=%substr(col%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
226
+ put ' proc sql noprint; ';
227
+ put ' create table &tmpds1 as ';
228
+ put ' select cats(libname,''.'',memname) as fmtcat, ';
229
+ put ' fmtname ';
230
+ put ' from dictionary.formats ';
231
+ put ' where fmttype=''F'' and libname is not null ';
232
+ put ' and fmtname in (select format from &colinfo where format is not null) ';
233
+ put ' order by 1; ';
234
+ put ' create table &tmpds2( ';
235
+ put ' FMTNAME char(32), ';
236
+ put ' MAX num length=3 ';
237
+ put ' ); ';
238
+ put ' %local catlist cat fmtlist i; ';
239
+ put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
240
+ put ' %do i=1 %to %sysfunc(countw(&catlist,%str( ))); ';
241
+ put ' %let cat=%scan(&catlist,&i,%str( )); ';
242
+ put ' proc sql; ';
243
+ put ' select distinct fmtname into: fmtlist separated by '' '' ';
244
+ put ' from &tmpds1 where fmtcat="&cat"; ';
245
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
246
+ put ' select &fmtlist; ';
247
+ put ' run; ';
248
+ put ' proc sql; ';
249
+ put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
250
+ put ' %end; ';
251
+ put ' ';
252
+ put ' proc sql; ';
253
+ put ' create table &tmpds4 as ';
254
+ put ' select a.*, b.max as maxw ';
255
+ put ' from &colinfo a ';
256
+ put ' left join &tmpds2 b ';
257
+ put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
258
+ put ' order by a.varnum; ';
259
+ put ' data _null_; ';
260
+ put ' set &tmpds4; ';
261
+ put ' if not missing(maxw); ';
262
+ put ' call symputx( ';
263
+ put ' cats(''fmtlen'',_n_), ';
264
+ put ' /* vars need extra padding due to JSON escaping of special chars */ ';
265
+ put ' min(32767,ceil((max(length,maxw)+3)*1.5)) ';
266
+ put ' ,''l'' ';
267
+ put ' ); ';
268
+ put ' run; ';
269
+ put ' ';
270
+ put ' /* configure varlenchk - as we are explicitly shortening the variables */ ';
271
+ put ' %let optval=%sysfunc(getoption(varlenchk)); ';
272
+ put ' options varlenchk=NOWARN; ';
273
+ put ' data _data_(compress=char); ';
274
+ put ' /* shorten the new vars */ ';
275
+ put ' length ';
276
+ put ' %do i=1 %to &numcols; ';
277
+ put ' &&name&i $&&fmtlen&i ';
278
+ put ' %end; ';
279
+ put ' ; ';
210
280
  put ' /* rename on entry */ ';
211
281
  put ' set &ds(rename=( ';
212
282
  put ' %do i=1 %to &numcols; ';
213
- put ' &&name&i=&&newname&i ';
283
+ put ' &&name&i=&&newname&i ';
214
284
  put ' %end; ';
215
285
  put ' )); ';
286
+ put ' &stmt_obs; ';
287
+ put ' ';
288
+ put ' drop ';
289
+ put ' %do i=1 %to &numcols; ';
290
+ put ' &&newname&i ';
291
+ put ' %end; ';
292
+ put ' ; ';
216
293
  put ' %do i=1 %to &numcols; ';
217
- put ' /* formatted values can be up to length 32767 */ ';
218
- put ' length &&name&i $32767; ';
219
294
  put ' %if &&typelong&i=num %then %do; ';
220
- put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
295
+ put ' &&name&i=cats(put(&&newname&i,&&fmt&i)); ';
221
296
  put ' %end; ';
222
297
  put ' %else %do; ';
223
298
  put ' &&name&i=put(&&newname&i,&&fmt&i); ';
224
299
  put ' %end; ';
225
- put ' drop &&newname&i; ';
226
300
  put ' %end; ';
227
- put ' if _error_ then call symputx(''syscc'',1012); ';
301
+ put ' if _error_ then do; ';
302
+ put ' call symputx(''syscc'',1012); ';
303
+ put ' stop; ';
304
+ put ' end; ';
228
305
  put ' run; ';
229
306
  put ' %let fmtds=&syslast; ';
307
+ put ' options varlenchk=&optval; ';
230
308
  put ' %end; ';
231
309
  put ' ';
232
310
  put ' proc format; /* credit yabwon for special null removal */ ';
@@ -245,8 +323,8 @@ data _null_;
245
323
  put ' attrib _all_ label=''''; ';
246
324
  put ' %do i=1 %to &numcols; ';
247
325
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
248
- put ' length &&name&i $32767; ';
249
- put ' format &&name&i $32767.; ';
326
+ put ' length &&name&i $&&fmtlen&i...; ';
327
+ put ' format &&name&i $&&fmtlen&i...; ';
250
328
  put ' %end; ';
251
329
  put ' %end; ';
252
330
  put ' %if &fmt=Y %then %do; ';
@@ -368,8 +446,8 @@ data _null_;
368
446
  put ' %quote(&user) ';
369
447
  put ' ';
370
448
  put '%mend mf_getuser; ';
371
- put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
372
- put ' ,showmeta=N,maxobs=MAX ';
449
+ put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL ';
450
+ put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
373
451
  put '); ';
374
452
  put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
375
453
  put ' sasjs_tables; ';
@@ -442,8 +520,8 @@ data _null_;
442
520
  put '%else %if &action=CLOSE %then %do; ';
443
521
  put ' /* To avoid issues with _webout on EBI we use a temporary file */ ';
444
522
  put ' filename _sjsref temp lrecl=131068; ';
445
- put ' %if %str(&_debug) ge 131 %then %do; ';
446
- put ' /* if debug mode, send back first 10 records of each work table also */ ';
523
+ put ' %if %str(&workobs) > 0 %then %do; ';
524
+ put ' /* if debug mode, send back first XX records of each work table also */ ';
447
525
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
448
526
  put ' ods output Members=&tempds; ';
449
527
  put ' proc datasets library=WORK memtype=data; ';
@@ -467,7 +545,9 @@ data _null_;
467
545
  put ' put " ""&wt"" : {"; ';
468
546
  put ' put ''"nlobs":'' nlobs; ';
469
547
  put ' put '',"nvars":'' nvars; ';
470
- 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 ' ) ';
471
551
  put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
472
552
  put ' put "}"; ';
473
553
  put ' %end; ';
@@ -26,7 +26,7 @@
26
26
  @param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
27
27
  @param [in] ds The dataset to send back to the frontend
28
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
29
+ @param [in] fmt= (N) Setting Y converts all vars to their formatted values
30
30
  @param [out] fref= (_webout) The fileref to which to write the JSON
31
31
  @param [in] missing= (NULL) Special numeric missing values can be sent as NULL
32
32
  (eg `null`) or as STRING values (eg `".a"` or `".b"`)
@@ -34,18 +34,25 @@
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
 
40
43
  <h4> SAS Macros </h4>
41
44
  @li mp_jsonout.sas
42
45
 
46
+ <h4> Related Macros </h4>
47
+ @li ms_webout.sas
48
+ @li mv_webout.sas
49
+
43
50
  @version 9.3
44
51
  @author Allan Bowe
45
52
 
46
53
  **/
47
- %macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
48
- ,showmeta=N,maxobs=MAX
54
+ %macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL
55
+ ,showmeta=N,maxobs=MAX,workobs=0
49
56
  );
50
57
  %global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
51
58
  sasjs_tables;
@@ -118,8 +125,8 @@
118
125
  %else %if &action=CLOSE %then %do;
119
126
  /* To avoid issues with _webout on EBI we use a temporary file */
120
127
  filename _sjsref temp lrecl=131068;
121
- %if %str(&_debug) ge 131 %then %do;
122
- /* if debug mode, send back first 10 records of each work table also */
128
+ %if %str(&workobs) > 0 %then %do;
129
+ /* if debug mode, send back first XX records of each work table also */
123
130
  data;run;%let tempds=%scan(&syslast,2,.);
124
131
  ods output Members=&tempds;
125
132
  proc datasets library=WORK memtype=data;
@@ -143,7 +150,9 @@
143
150
  put " ""&wt"" : {";
144
151
  put '"nlobs":' nlobs;
145
152
  put ',"nvars":' nvars;
146
- %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
+ )
147
156
  data _null_; file _sjsref mod encoding='utf-8';
148
157
  put "}";
149
158
  %end;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.35.0"
38
+ "version": "4.35.3"
39
39
  }
@@ -94,14 +94,14 @@ data _null_;
94
94
  file &sasjsref termstr=crlf lrecl=512;
95
95
  put "/* Created on %sysfunc(datetime(),datetime19.) by %mf_getuser() */";
96
96
  /* WEBOUT BEGIN */
97
- put ' ';
98
97
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
99
98
  put ' ,engine=DATASTEP ';
100
99
  put ' ,missing=NULL ';
101
100
  put ' ,showmeta=N ';
102
101
  put ' ,maxobs=MAX ';
103
102
  put ')/*/STORE SOURCE*/; ';
104
- put '%local tempds colinfo fmtds i numcols stmt_obs; ';
103
+ put '%local tempds colinfo fmtds i numcols numobs stmt_obs lastobs optval ';
104
+ put ' tmpds1 tmpds2 tmpds3 tmpds4; ';
105
105
  put '%let numcols=0; ';
106
106
  put '%if &maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
107
107
  put ' ';
@@ -139,7 +139,7 @@ data _null_;
139
139
  put ' by varnum; ';
140
140
  put ' run; ';
141
141
  put ' /* move meta to mac vars */ ';
142
- put ' data _null_; ';
142
+ put ' data &colinfo; ';
143
143
  put ' if _n_=1 then call symputx(''numcols'',nobs,''l''); ';
144
144
  put ' set &colinfo end=last nobs=nobs; ';
145
145
  put ' name=upcase(name); ';
@@ -168,9 +168,15 @@ data _null_;
168
168
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
169
169
  put ' call symputx(cats(''typelong'',_n_),typelong,''l''); ';
170
170
  put ' call symputx(cats(''label'',_n_),coalescec(label,name),''l''); ';
171
+ put ' /* overwritten when fmt=Y and a custom format exists in catalog */ ';
172
+ put ' if typelong=''num'' then call symputx(cats(''fmtlen'',_n_),200,''l''); ';
173
+ put ' else call symputx(cats(''fmtlen'',_n_),min(32767,ceil((length+3)*1.5)),''l''); ';
171
174
  put ' run; ';
172
175
  put ' ';
173
176
  put ' %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
177
+ put ' proc sql; ';
178
+ put ' select count(*) into: lastobs from &ds; ';
179
+ put ' %if &maxobs ne MAX %then %let lastobs=%sysfunc(min(&lastobs,&maxobs)); ';
174
180
  put ' ';
175
181
  put ' %if &engine=PROCJSON %then %do; ';
176
182
  put ' %if &missing=STRING %then %do; ';
@@ -207,27 +213,99 @@ data _null_;
207
213
  put ' %end; ';
208
214
  put ' ';
209
215
  put ' %if &fmt=Y %then %do; ';
210
- put ' data _data_; ';
216
+ put ' /** ';
217
+ put ' * Extract format definitions ';
218
+ put ' * First, by getting library locations from dictionary.formats ';
219
+ put ' * Then, by exporting the width using proc format ';
220
+ put ' * Cannot use maxw from sashelp.vformat as not always populated ';
221
+ put ' * Cannot use fmtinfo() as not supported in all flavours ';
222
+ put ' */ ';
223
+ put ' %let tmpds1=%substr(fmtsum%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
224
+ put ' %let tmpds2=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
225
+ put ' %let tmpds3=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
226
+ put ' %let tmpds4=%substr(col%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
227
+ put ' proc sql noprint; ';
228
+ put ' create table &tmpds1 as ';
229
+ put ' select cats(libname,''.'',memname) as fmtcat, ';
230
+ put ' fmtname ';
231
+ put ' from dictionary.formats ';
232
+ put ' where fmttype=''F'' and libname is not null ';
233
+ put ' and fmtname in (select format from &colinfo where format is not null) ';
234
+ put ' order by 1; ';
235
+ put ' create table &tmpds2( ';
236
+ put ' FMTNAME char(32), ';
237
+ put ' MAX num length=3 ';
238
+ put ' ); ';
239
+ put ' %local catlist cat fmtlist i; ';
240
+ put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
241
+ put ' %do i=1 %to %sysfunc(countw(&catlist,%str( ))); ';
242
+ put ' %let cat=%scan(&catlist,&i,%str( )); ';
243
+ put ' proc sql; ';
244
+ put ' select distinct fmtname into: fmtlist separated by '' '' ';
245
+ put ' from &tmpds1 where fmtcat="&cat"; ';
246
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
247
+ put ' select &fmtlist; ';
248
+ put ' run; ';
249
+ put ' proc sql; ';
250
+ put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
251
+ put ' %end; ';
252
+ put ' ';
253
+ put ' proc sql; ';
254
+ put ' create table &tmpds4 as ';
255
+ put ' select a.*, b.max as maxw ';
256
+ put ' from &colinfo a ';
257
+ put ' left join &tmpds2 b ';
258
+ put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
259
+ put ' order by a.varnum; ';
260
+ put ' data _null_; ';
261
+ put ' set &tmpds4; ';
262
+ put ' if not missing(maxw); ';
263
+ put ' call symputx( ';
264
+ put ' cats(''fmtlen'',_n_), ';
265
+ put ' /* vars need extra padding due to JSON escaping of special chars */ ';
266
+ put ' min(32767,ceil((max(length,maxw)+3)*1.5)) ';
267
+ put ' ,''l'' ';
268
+ put ' ); ';
269
+ put ' run; ';
270
+ put ' ';
271
+ put ' /* configure varlenchk - as we are explicitly shortening the variables */ ';
272
+ put ' %let optval=%sysfunc(getoption(varlenchk)); ';
273
+ put ' options varlenchk=NOWARN; ';
274
+ put ' data _data_(compress=char); ';
275
+ put ' /* shorten the new vars */ ';
276
+ put ' length ';
277
+ put ' %do i=1 %to &numcols; ';
278
+ put ' &&name&i $&&fmtlen&i ';
279
+ put ' %end; ';
280
+ put ' ; ';
211
281
  put ' /* rename on entry */ ';
212
282
  put ' set &ds(rename=( ';
213
283
  put ' %do i=1 %to &numcols; ';
214
- put ' &&name&i=&&newname&i ';
284
+ put ' &&name&i=&&newname&i ';
215
285
  put ' %end; ';
216
286
  put ' )); ';
287
+ put ' &stmt_obs; ';
288
+ put ' ';
289
+ put ' drop ';
290
+ put ' %do i=1 %to &numcols; ';
291
+ put ' &&newname&i ';
292
+ put ' %end; ';
293
+ put ' ; ';
217
294
  put ' %do i=1 %to &numcols; ';
218
- put ' /* formatted values can be up to length 32767 */ ';
219
- put ' length &&name&i $32767; ';
220
295
  put ' %if &&typelong&i=num %then %do; ';
221
- put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
296
+ put ' &&name&i=cats(put(&&newname&i,&&fmt&i)); ';
222
297
  put ' %end; ';
223
298
  put ' %else %do; ';
224
299
  put ' &&name&i=put(&&newname&i,&&fmt&i); ';
225
300
  put ' %end; ';
226
- put ' drop &&newname&i; ';
227
301
  put ' %end; ';
228
- put ' if _error_ then call symputx(''syscc'',1012); ';
302
+ put ' if _error_ then do; ';
303
+ put ' call symputx(''syscc'',1012); ';
304
+ put ' stop; ';
305
+ put ' end; ';
229
306
  put ' run; ';
230
307
  put ' %let fmtds=&syslast; ';
308
+ put ' options varlenchk=&optval; ';
231
309
  put ' %end; ';
232
310
  put ' ';
233
311
  put ' proc format; /* credit yabwon for special null removal */ ';
@@ -246,8 +324,8 @@ data _null_;
246
324
  put ' attrib _all_ label=''''; ';
247
325
  put ' %do i=1 %to &numcols; ';
248
326
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
249
- put ' length &&name&i $32767; ';
250
- put ' format &&name&i $32767.; ';
327
+ put ' length &&name&i $&&fmtlen&i...; ';
328
+ put ' format &&name&i $&&fmtlen&i...; ';
251
329
  put ' %end; ';
252
330
  put ' %end; ';
253
331
  put ' %if &fmt=Y %then %do; ';
@@ -370,8 +448,8 @@ data _null_;
370
448
  put ' ';
371
449
  put '%mend mf_getuser; ';
372
450
  put ' ';
373
- put '%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
374
- put ' ,showmeta=N,maxobs=MAX ';
451
+ put '%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL ';
452
+ put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
375
453
  put '); ';
376
454
  put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
377
455
  put ' sasjs_tables; ';
@@ -434,8 +512,8 @@ data _null_;
434
512
  put ' ) ';
435
513
  put '%end; ';
436
514
  put '%else %if &action=CLOSE %then %do; ';
437
- put ' %if %str(&_debug) ge 131 %then %do; ';
438
- put ' /* if debug mode, send back first 10 records of each work table also */ ';
515
+ put ' %if %str(&workobs) > 0 %then %do; ';
516
+ put ' /* if debug mode, send back first XX records of each work table also */ ';
439
517
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
440
518
  put ' ods output Members=&tempds; ';
441
519
  put ' proc datasets library=WORK memtype=data; ';
@@ -460,7 +538,9 @@ data _null_;
460
538
  put ' put " ""&wt"" : {"; ';
461
539
  put ' put ''"nlobs":'' nlobs; ';
462
540
  put ' put '',"nvars":'' nvars; ';
463
- 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 ' ) ';
464
544
  put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
465
545
  put ' put "}"; ';
466
546
  put ' %end; ';
@@ -23,7 +23,7 @@
23
23
  @param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
24
24
  @param [in] ds The dataset to send back to the frontend
25
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
26
+ @param [in] fmt= (N) Setting Y converts all vars to their formatted values
27
27
  @param [out] fref= (_webout) The fileref to which to write the JSON
28
28
  @param [in] missing= (NULL) Special numeric missing values can be sent as NULL
29
29
  (eg `null`) or as STRING values (eg `".a"` or `".b"`)
@@ -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
 
@@ -48,8 +51,8 @@
48
51
 
49
52
  **/
50
53
 
51
- %macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
52
- ,showmeta=N,maxobs=MAX
54
+ %macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=N,missing=NULL
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(&_debug) ge 131 %then %do;
116
- /* if debug mode, send back first 10 records of each work table also */
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;
@@ -236,14 +236,14 @@ data _null_;
236
236
  file &adapter;
237
237
  put "/* Created on %sysfunc(datetime(),datetime19.) by &sysuserid */";
238
238
  /* WEBOUT BEGIN */
239
- put ' ';
240
239
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
241
240
  put ' ,engine=DATASTEP ';
242
241
  put ' ,missing=NULL ';
243
242
  put ' ,showmeta=N ';
244
243
  put ' ,maxobs=MAX ';
245
244
  put ')/*/STORE SOURCE*/; ';
246
- put '%local tempds colinfo fmtds i numcols stmt_obs; ';
245
+ put '%local tempds colinfo fmtds i numcols numobs stmt_obs lastobs optval ';
246
+ put ' tmpds1 tmpds2 tmpds3 tmpds4; ';
247
247
  put '%let numcols=0; ';
248
248
  put '%if &maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
249
249
  put ' ';
@@ -281,7 +281,7 @@ data _null_;
281
281
  put ' by varnum; ';
282
282
  put ' run; ';
283
283
  put ' /* move meta to mac vars */ ';
284
- put ' data _null_; ';
284
+ put ' data &colinfo; ';
285
285
  put ' if _n_=1 then call symputx(''numcols'',nobs,''l''); ';
286
286
  put ' set &colinfo end=last nobs=nobs; ';
287
287
  put ' name=upcase(name); ';
@@ -310,9 +310,15 @@ data _null_;
310
310
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
311
311
  put ' call symputx(cats(''typelong'',_n_),typelong,''l''); ';
312
312
  put ' call symputx(cats(''label'',_n_),coalescec(label,name),''l''); ';
313
+ put ' /* overwritten when fmt=Y and a custom format exists in catalog */ ';
314
+ put ' if typelong=''num'' then call symputx(cats(''fmtlen'',_n_),200,''l''); ';
315
+ put ' else call symputx(cats(''fmtlen'',_n_),min(32767,ceil((length+3)*1.5)),''l''); ';
313
316
  put ' run; ';
314
317
  put ' ';
315
318
  put ' %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
319
+ put ' proc sql; ';
320
+ put ' select count(*) into: lastobs from &ds; ';
321
+ put ' %if &maxobs ne MAX %then %let lastobs=%sysfunc(min(&lastobs,&maxobs)); ';
316
322
  put ' ';
317
323
  put ' %if &engine=PROCJSON %then %do; ';
318
324
  put ' %if &missing=STRING %then %do; ';
@@ -349,27 +355,99 @@ data _null_;
349
355
  put ' %end; ';
350
356
  put ' ';
351
357
  put ' %if &fmt=Y %then %do; ';
352
- put ' data _data_; ';
358
+ put ' /** ';
359
+ put ' * Extract format definitions ';
360
+ put ' * First, by getting library locations from dictionary.formats ';
361
+ put ' * Then, by exporting the width using proc format ';
362
+ put ' * Cannot use maxw from sashelp.vformat as not always populated ';
363
+ put ' * Cannot use fmtinfo() as not supported in all flavours ';
364
+ put ' */ ';
365
+ put ' %let tmpds1=%substr(fmtsum%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
366
+ put ' %let tmpds2=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
367
+ put ' %let tmpds3=%substr(cntl%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
368
+ put ' %let tmpds4=%substr(col%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
369
+ put ' proc sql noprint; ';
370
+ put ' create table &tmpds1 as ';
371
+ put ' select cats(libname,''.'',memname) as fmtcat, ';
372
+ put ' fmtname ';
373
+ put ' from dictionary.formats ';
374
+ put ' where fmttype=''F'' and libname is not null ';
375
+ put ' and fmtname in (select format from &colinfo where format is not null) ';
376
+ put ' order by 1; ';
377
+ put ' create table &tmpds2( ';
378
+ put ' FMTNAME char(32), ';
379
+ put ' MAX num length=3 ';
380
+ put ' ); ';
381
+ put ' %local catlist cat fmtlist i; ';
382
+ put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
383
+ put ' %do i=1 %to %sysfunc(countw(&catlist,%str( ))); ';
384
+ put ' %let cat=%scan(&catlist,&i,%str( )); ';
385
+ put ' proc sql; ';
386
+ put ' select distinct fmtname into: fmtlist separated by '' '' ';
387
+ put ' from &tmpds1 where fmtcat="&cat"; ';
388
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
389
+ put ' select &fmtlist; ';
390
+ put ' run; ';
391
+ put ' proc sql; ';
392
+ put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
393
+ put ' %end; ';
394
+ put ' ';
395
+ put ' proc sql; ';
396
+ put ' create table &tmpds4 as ';
397
+ put ' select a.*, b.max as maxw ';
398
+ put ' from &colinfo a ';
399
+ put ' left join &tmpds2 b ';
400
+ put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
401
+ put ' order by a.varnum; ';
402
+ put ' data _null_; ';
403
+ put ' set &tmpds4; ';
404
+ put ' if not missing(maxw); ';
405
+ put ' call symputx( ';
406
+ put ' cats(''fmtlen'',_n_), ';
407
+ put ' /* vars need extra padding due to JSON escaping of special chars */ ';
408
+ put ' min(32767,ceil((max(length,maxw)+3)*1.5)) ';
409
+ put ' ,''l'' ';
410
+ put ' ); ';
411
+ put ' run; ';
412
+ put ' ';
413
+ put ' /* configure varlenchk - as we are explicitly shortening the variables */ ';
414
+ put ' %let optval=%sysfunc(getoption(varlenchk)); ';
415
+ put ' options varlenchk=NOWARN; ';
416
+ put ' data _data_(compress=char); ';
417
+ put ' /* shorten the new vars */ ';
418
+ put ' length ';
419
+ put ' %do i=1 %to &numcols; ';
420
+ put ' &&name&i $&&fmtlen&i ';
421
+ put ' %end; ';
422
+ put ' ; ';
353
423
  put ' /* rename on entry */ ';
354
424
  put ' set &ds(rename=( ';
355
425
  put ' %do i=1 %to &numcols; ';
356
- put ' &&name&i=&&newname&i ';
426
+ put ' &&name&i=&&newname&i ';
357
427
  put ' %end; ';
358
428
  put ' )); ';
429
+ put ' &stmt_obs; ';
430
+ put ' ';
431
+ put ' drop ';
432
+ put ' %do i=1 %to &numcols; ';
433
+ put ' &&newname&i ';
434
+ put ' %end; ';
435
+ put ' ; ';
359
436
  put ' %do i=1 %to &numcols; ';
360
- put ' /* formatted values can be up to length 32767 */ ';
361
- put ' length &&name&i $32767; ';
362
437
  put ' %if &&typelong&i=num %then %do; ';
363
- put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
438
+ put ' &&name&i=cats(put(&&newname&i,&&fmt&i)); ';
364
439
  put ' %end; ';
365
440
  put ' %else %do; ';
366
441
  put ' &&name&i=put(&&newname&i,&&fmt&i); ';
367
442
  put ' %end; ';
368
- put ' drop &&newname&i; ';
369
443
  put ' %end; ';
370
- put ' if _error_ then call symputx(''syscc'',1012); ';
444
+ put ' if _error_ then do; ';
445
+ put ' call symputx(''syscc'',1012); ';
446
+ put ' stop; ';
447
+ put ' end; ';
371
448
  put ' run; ';
372
449
  put ' %let fmtds=&syslast; ';
450
+ put ' options varlenchk=&optval; ';
373
451
  put ' %end; ';
374
452
  put ' ';
375
453
  put ' proc format; /* credit yabwon for special null removal */ ';
@@ -388,8 +466,8 @@ data _null_;
388
466
  put ' attrib _all_ label=''''; ';
389
467
  put ' %do i=1 %to &numcols; ';
390
468
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
391
- put ' length &&name&i $32767; ';
392
- put ' format &&name&i $32767.; ';
469
+ put ' length &&name&i $&&fmtlen&i...; ';
470
+ put ' format &&name&i $&&fmtlen&i...; ';
393
471
  put ' %end; ';
394
472
  put ' %end; ';
395
473
  put ' %if &fmt=Y %then %do; ';
@@ -511,8 +589,8 @@ data _null_;
511
589
  put ' %quote(&user) ';
512
590
  put ' ';
513
591
  put '%mend mf_getuser; ';
514
- put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL ';
515
- put ' ,showmeta=N,maxobs=MAX ';
592
+ put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=N,stream=Y,missing=NULL ';
593
+ put ' ,showmeta=N,maxobs=MAX,workobs=0 ';
516
594
  put '); ';
517
595
  put '%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name ';
518
596
  put ' sasjs_tables SYS_JES_JOB_URI; ';
@@ -619,8 +697,8 @@ data _null_;
619
697
  put ' ) ';
620
698
  put '%end; ';
621
699
  put '%else %if &action=CLOSE %then %do; ';
622
- put ' %if %str(&_debug) ge 131 %then %do; ';
623
- put ' /* send back first 10 records of each work table for debugging */ ';
700
+ put ' %if %str(&workobs) > 0 %then %do; ';
701
+ put ' /* send back first XX records of each work table for debugging */ ';
624
702
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
625
703
  put ' ods output Members=&tempds; ';
626
704
  put ' proc datasets library=WORK memtype=data; ';
@@ -643,7 +721,9 @@ data _null_;
643
721
  put ' put " ""&wt"" : {"; ';
644
722
  put ' put ''"nlobs":'' nlobs; ';
645
723
  put ' put '',"nvars":'' nvars; ';
646
- put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10) ';
724
+ put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y ';
725
+ put ' ,maxobs=&workobs ';
726
+ put ' ) ';
647
727
  put ' data _null_; file &fref mod;put "}"; ';
648
728
  put ' %end; ';
649
729
  put ' data _null_; file &fref mod;put "}";run; ';
@@ -25,7 +25,7 @@
25
25
  @param [in] _webout= fileref for returning the json
26
26
  @param [out] fref=(_mvwtemp) Temp fileref to which to write the output
27
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
28
+ @param [in] fmt= (N) Setting Y converts all vars to their formatted values
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"`)
@@ -35,17 +35,24 @@
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
41
44
  @li mf_getuser.sas
42
45
 
46
+ <h4> Related Macros </h4>
47
+ @li ms_webout.sas
48
+ @li mm_webout.sas
49
+
43
50
  @version Viya 3.3
44
51
  @author Allan Bowe, source: https://github.com/sasjs/core
45
52
 
46
53
  **/
47
- %macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL
48
- ,showmeta=N,maxobs=MAX
54
+ %macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=N,stream=Y,missing=NULL
55
+ ,showmeta=N,maxobs=MAX,workobs=0
49
56
  );
50
57
  %global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
51
58
  sasjs_tables SYS_JES_JOB_URI;
@@ -152,8 +159,8 @@
152
159
  )
153
160
  %end;
154
161
  %else %if &action=CLOSE %then %do;
155
- %if %str(&_debug) ge 131 %then %do;
156
- /* send back first 10 records of each work table for debugging */
162
+ %if %str(&workobs) > 0 %then %do;
163
+ /* send back first XX records of each work table for debugging */
157
164
  data;run;%let tempds=%scan(&syslast,2,.);
158
165
  ods output Members=&tempds;
159
166
  proc datasets library=WORK memtype=data;
@@ -176,7 +183,9 @@
176
183
  put " ""&wt"" : {";
177
184
  put '"nlobs":' nlobs;
178
185
  put ',"nvars":' nvars;
179
- %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10)
186
+ %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
187
+ ,maxobs=&workobs
188
+ )
180
189
  data _null_; file &fref mod;put "}";
181
190
  %end;
182
191
  data _null_; file &fref mod;put "}";run;