@sasjs/core 4.32.4 → 4.32.5

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.
@@ -28,7 +28,7 @@
28
28
 
29
29
  %mp_jsonout(OPEN,jref=tmp)
30
30
  %mp_jsonout(OBJ,class,jref=tmp)
31
- %mp_jsonout(OBJ,class,dslabel=class2,jref=tmp,showmeta=YES)
31
+ %mp_jsonout(OBJ,class,dslabel=class2,jref=tmp,showmeta=Y)
32
32
  %mp_jsonout(CLOSE,jref=tmp)
33
33
 
34
34
  data _null_;
@@ -55,10 +55,12 @@
55
55
  @li DATASTEP (more reliable when data has non standard characters)
56
56
  @param [in] missing= (NULL) Special numeric missing values can be sent as NULL
57
57
  (eg `null`) or as STRING values (eg `".a"` or `".b"`)
58
- @param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
58
+ @param [in] showmeta= (N) Set to Y to output metadata alongside each table,
59
59
  such as the column formats and types. The metadata is contained inside an
60
60
  object with the same name as the table but prefixed with a dollar sign - ie,
61
61
  `,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
62
+ @param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
63
+ that should be converted to JSON
62
64
 
63
65
  <h4> Related Macros <h4>
64
66
  @li mp_ds2fmtds.sas
@@ -72,10 +74,12 @@
72
74
  %macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y
73
75
  ,engine=DATASTEP
74
76
  ,missing=NULL
75
- ,showmeta=NO
77
+ ,showmeta=N
78
+ ,maxobs=MAX
76
79
  )/*/STORE SOURCE*/;
77
- %local tempds colinfo fmtds i numcols;
80
+ %local tempds colinfo fmtds i numcols stmt_obs;
78
81
  %let numcols=0;
82
+ %if maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;);
79
83
 
80
84
  %if &action=OPEN %then %do;
81
85
  options nobomfile;
@@ -154,7 +158,9 @@
154
158
  %put &sysmacroname: Switching to DATASTEP engine;
155
159
  %goto datastep;
156
160
  %end;
157
- data &tempds;set &ds;
161
+ data &tempds;
162
+ set &ds;
163
+ &stmt_obs;
158
164
  %if &fmt=N %then format _numeric_ best32.;;
159
165
  /* PRETTY is necessary to avoid line truncation in large files */
160
166
  filename _sjs2 temp lrecl=131068 encoding='utf-8';
@@ -229,6 +235,7 @@
229
235
  %else %do;
230
236
  set &ds;
231
237
  %end;
238
+ &stmt_obs;
232
239
  format _numeric_ bart.;
233
240
  %do i=1 %to &numcols;
234
241
  %if &&typelong&i=char or &fmt=Y %then %do;
@@ -285,7 +292,7 @@
285
292
  proc sql;
286
293
  drop table &colinfo, &tempds;
287
294
 
288
- %if &showmeta=YES %then %do;
295
+ %if %substr(&showmeta,1,1)=Y %then %do;
289
296
  filename _sjs4 temp lrecl=131068 encoding='utf-8';
290
297
  data _null_;
291
298
  file _sjs4;
@@ -97,10 +97,12 @@ data _null_;
97
97
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
98
98
  put ' ,engine=DATASTEP ';
99
99
  put ' ,missing=NULL ';
100
- put ' ,showmeta=NO ';
100
+ put ' ,showmeta=N ';
101
+ put ' ,maxobs=MAX ';
101
102
  put ')/*/STORE SOURCE*/; ';
102
- put '%local tempds colinfo fmtds i numcols; ';
103
+ put '%local tempds colinfo fmtds i numcols stmt_obs; ';
103
104
  put '%let numcols=0; ';
105
+ put '%if maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
104
106
  put ' ';
105
107
  put '%if &action=OPEN %then %do; ';
106
108
  put ' options nobomfile; ';
@@ -179,7 +181,9 @@ data _null_;
179
181
  put ' %put &sysmacroname: Switching to DATASTEP engine; ';
180
182
  put ' %goto datastep; ';
181
183
  put ' %end; ';
182
- put ' data &tempds;set &ds; ';
184
+ put ' data &tempds; ';
185
+ put ' set &ds; ';
186
+ put ' &stmt_obs; ';
183
187
  put ' %if &fmt=N %then format _numeric_ best32.;; ';
184
188
  put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
185
189
  put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
@@ -254,6 +258,7 @@ data _null_;
254
258
  put ' %else %do; ';
255
259
  put ' set &ds; ';
256
260
  put ' %end; ';
261
+ put ' &stmt_obs; ';
257
262
  put ' format _numeric_ bart.; ';
258
263
  put ' %do i=1 %to &numcols; ';
259
264
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
@@ -310,7 +315,7 @@ data _null_;
310
315
  put ' proc sql; ';
311
316
  put ' drop table &colinfo, &tempds; ';
312
317
  put ' ';
313
- put ' %if &showmeta=YES %then %do; ';
318
+ put ' %if %substr(&showmeta,1,1)=Y %then %do; ';
314
319
  put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
315
320
  put ' data _null_; ';
316
321
  put ' file _sjs4; ';
@@ -366,7 +371,7 @@ data _null_;
366
371
  put ' ';
367
372
  put '%mend mf_getuser; ';
368
373
  put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
369
- put ' ,showmeta=NO ';
374
+ put ' ,showmeta=N ';
370
375
  put '); ';
371
376
  put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
372
377
  put ' sasjs_tables; ';
@@ -441,7 +446,6 @@ data _null_;
441
446
  put ' filename _sjsref temp lrecl=131068; ';
442
447
  put ' %if %str(&_debug) ge 131 %then %do; ';
443
448
  put ' /* if debug mode, send back first 10 records of each work table also */ ';
444
- put ' options obs=10; ';
445
449
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
446
450
  put ' ods output Members=&tempds; ';
447
451
  put ' proc datasets library=WORK memtype=data; ';
@@ -465,7 +469,7 @@ data _null_;
465
469
  put ' put " ""&wt"" : {"; ';
466
470
  put ' put ''"nlobs":'' nlobs; ';
467
471
  put ' put '',"nvars":'' nvars; ';
468
- put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES) ';
472
+ put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10) ';
469
473
  put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
470
474
  put ' put "}"; ';
471
475
  put ' %end; ';
@@ -30,7 +30,7 @@
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"`)
33
- @param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
33
+ @param [in] showmeta= (N) Set to Y to output metadata alongside each table,
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"}}`
@@ -44,7 +44,7 @@
44
44
 
45
45
  **/
46
46
  %macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
47
- ,showmeta=NO
47
+ ,showmeta=N
48
48
  );
49
49
  %global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
50
50
  sasjs_tables;
@@ -119,7 +119,6 @@
119
119
  filename _sjsref temp lrecl=131068;
120
120
  %if %str(&_debug) ge 131 %then %do;
121
121
  /* if debug mode, send back first 10 records of each work table also */
122
- options obs=10;
123
122
  data;run;%let tempds=%scan(&syslast,2,.);
124
123
  ods output Members=&tempds;
125
124
  proc datasets library=WORK memtype=data;
@@ -143,7 +142,7 @@
143
142
  put " ""&wt"" : {";
144
143
  put '"nlobs":' nlobs;
145
144
  put ',"nvars":' nvars;
146
- %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES)
145
+ %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10)
147
146
  data _null_; file _sjsref mod encoding='utf-8';
148
147
  put "}";
149
148
  %end;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.32.4"
38
+ "version": "4.32.5"
39
39
  }
@@ -98,10 +98,12 @@ data _null_;
98
98
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
99
99
  put ' ,engine=DATASTEP ';
100
100
  put ' ,missing=NULL ';
101
- put ' ,showmeta=NO ';
101
+ put ' ,showmeta=N ';
102
+ put ' ,maxobs=MAX ';
102
103
  put ')/*/STORE SOURCE*/; ';
103
- put '%local tempds colinfo fmtds i numcols; ';
104
+ put '%local tempds colinfo fmtds i numcols stmt_obs; ';
104
105
  put '%let numcols=0; ';
106
+ put '%if maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
105
107
  put ' ';
106
108
  put '%if &action=OPEN %then %do; ';
107
109
  put ' options nobomfile; ';
@@ -180,7 +182,9 @@ data _null_;
180
182
  put ' %put &sysmacroname: Switching to DATASTEP engine; ';
181
183
  put ' %goto datastep; ';
182
184
  put ' %end; ';
183
- put ' data &tempds;set &ds; ';
185
+ put ' data &tempds; ';
186
+ put ' set &ds; ';
187
+ put ' &stmt_obs; ';
184
188
  put ' %if &fmt=N %then format _numeric_ best32.;; ';
185
189
  put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
186
190
  put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
@@ -255,6 +259,7 @@ data _null_;
255
259
  put ' %else %do; ';
256
260
  put ' set &ds; ';
257
261
  put ' %end; ';
262
+ put ' &stmt_obs; ';
258
263
  put ' format _numeric_ bart.; ';
259
264
  put ' %do i=1 %to &numcols; ';
260
265
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
@@ -311,7 +316,7 @@ data _null_;
311
316
  put ' proc sql; ';
312
317
  put ' drop table &colinfo, &tempds; ';
313
318
  put ' ';
314
- put ' %if &showmeta=YES %then %do; ';
319
+ put ' %if %substr(&showmeta,1,1)=Y %then %do; ';
315
320
  put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
316
321
  put ' data _null_; ';
317
322
  put ' file _sjs4; ';
@@ -368,7 +373,7 @@ data _null_;
368
373
  put '%mend mf_getuser; ';
369
374
  put ' ';
370
375
  put '%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
371
- put ' ,showmeta=NO ';
376
+ put ' ,showmeta=N ';
372
377
  put '); ';
373
378
  put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
374
379
  put ' sasjs_tables; ';
@@ -433,7 +438,6 @@ data _null_;
433
438
  put '%else %if &action=CLOSE %then %do; ';
434
439
  put ' %if %str(&_debug) ge 131 %then %do; ';
435
440
  put ' /* if debug mode, send back first 10 records of each work table also */ ';
436
- put ' options obs=10; ';
437
441
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
438
442
  put ' ods output Members=&tempds; ';
439
443
  put ' proc datasets library=WORK memtype=data; ';
@@ -458,7 +462,7 @@ data _null_;
458
462
  put ' put " ""&wt"" : {"; ';
459
463
  put ' put ''"nlobs":'' nlobs; ';
460
464
  put ' put '',"nvars":'' nvars; ';
461
- put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
465
+ put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10) ';
462
466
  put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
463
467
  put ' put "}"; ';
464
468
  put ' %end; ';
@@ -27,7 +27,7 @@
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"`)
30
- @param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
30
+ @param [in] showmeta= (N) Set to Y to output metadata alongside each table,
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"}}`
@@ -47,7 +47,7 @@
47
47
  **/
48
48
 
49
49
  %macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
50
- ,showmeta=NO
50
+ ,showmeta=N
51
51
  );
52
52
  %global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
53
53
  sasjs_tables;
@@ -112,7 +112,6 @@
112
112
  %else %if &action=CLOSE %then %do;
113
113
  %if %str(&_debug) ge 131 %then %do;
114
114
  /* if debug mode, send back first 10 records of each work table also */
115
- options obs=10;
116
115
  data;run;%let tempds=%scan(&syslast,2,.);
117
116
  ods output Members=&tempds;
118
117
  proc datasets library=WORK memtype=data;
@@ -137,7 +136,7 @@
137
136
  put " ""&wt"" : {";
138
137
  put '"nlobs":' nlobs;
139
138
  put ',"nvars":' nvars;
140
- %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
139
+ %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10)
141
140
  data _null_; file &fref mod encoding='utf-8' termstr=lf;
142
141
  put "}";
143
142
  %end;
@@ -240,10 +240,12 @@ data _null_;
240
240
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
241
241
  put ' ,engine=DATASTEP ';
242
242
  put ' ,missing=NULL ';
243
- put ' ,showmeta=NO ';
243
+ put ' ,showmeta=N ';
244
+ put ' ,maxobs=MAX ';
244
245
  put ')/*/STORE SOURCE*/; ';
245
- put '%local tempds colinfo fmtds i numcols; ';
246
+ put '%local tempds colinfo fmtds i numcols stmt_obs; ';
246
247
  put '%let numcols=0; ';
248
+ put '%if maxobs ne MAX %then %let stmt_obs=%str(if _n_>&maxobs then stop;); ';
247
249
  put ' ';
248
250
  put '%if &action=OPEN %then %do; ';
249
251
  put ' options nobomfile; ';
@@ -322,7 +324,9 @@ data _null_;
322
324
  put ' %put &sysmacroname: Switching to DATASTEP engine; ';
323
325
  put ' %goto datastep; ';
324
326
  put ' %end; ';
325
- put ' data &tempds;set &ds; ';
327
+ put ' data &tempds; ';
328
+ put ' set &ds; ';
329
+ put ' &stmt_obs; ';
326
330
  put ' %if &fmt=N %then format _numeric_ best32.;; ';
327
331
  put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
328
332
  put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
@@ -397,6 +401,7 @@ data _null_;
397
401
  put ' %else %do; ';
398
402
  put ' set &ds; ';
399
403
  put ' %end; ';
404
+ put ' &stmt_obs; ';
400
405
  put ' format _numeric_ bart.; ';
401
406
  put ' %do i=1 %to &numcols; ';
402
407
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
@@ -453,7 +458,7 @@ data _null_;
453
458
  put ' proc sql; ';
454
459
  put ' drop table &colinfo, &tempds; ';
455
460
  put ' ';
456
- put ' %if &showmeta=YES %then %do; ';
461
+ put ' %if %substr(&showmeta,1,1)=Y %then %do; ';
457
462
  put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
458
463
  put ' data _null_; ';
459
464
  put ' file _sjs4; ';
@@ -509,7 +514,7 @@ data _null_;
509
514
  put ' ';
510
515
  put '%mend mf_getuser; ';
511
516
  put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL ';
512
- put ' ,showmeta=NO ';
517
+ put ' ,showmeta=N ';
513
518
  put '); ';
514
519
  put '%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name ';
515
520
  put ' sasjs_tables SYS_JES_JOB_URI; ';
@@ -619,7 +624,6 @@ data _null_;
619
624
  put '%else %if &action=CLOSE %then %do; ';
620
625
  put ' %if %str(&_debug) ge 131 %then %do; ';
621
626
  put ' /* send back first 10 records of each work table for debugging */ ';
622
- put ' options obs=10; ';
623
627
  put ' data;run;%let tempds=%scan(&syslast,2,.); ';
624
628
  put ' ods output Members=&tempds; ';
625
629
  put ' proc datasets library=WORK memtype=data; ';
@@ -642,7 +646,7 @@ data _null_;
642
646
  put ' put " ""&wt"" : {"; ';
643
647
  put ' put ''"nlobs":'' nlobs; ';
644
648
  put ' put '',"nvars":'' nvars; ';
645
- put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
649
+ put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10) ';
646
650
  put ' data _null_; file &fref mod;put "}"; ';
647
651
  put ' %end; ';
648
652
  put ' data _null_; file &fref mod;put "}";run; ';
@@ -29,7 +29,7 @@
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,
32
+ @param [in] showmeta= (N) Set to Y to output metadata alongside each table,
33
33
  such as the column formats and types. The metadata is contained inside an
34
34
  object with the same name as the table but prefixed with a dollar sign - ie,
35
35
  `,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
@@ -43,7 +43,7 @@
43
43
 
44
44
  **/
45
45
  %macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL
46
- ,showmeta=NO
46
+ ,showmeta=N
47
47
  );
48
48
  %global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
49
49
  sasjs_tables SYS_JES_JOB_URI;
@@ -153,7 +153,6 @@
153
153
  %else %if &action=CLOSE %then %do;
154
154
  %if %str(&_debug) ge 131 %then %do;
155
155
  /* send back first 10 records of each work table for debugging */
156
- options obs=10;
157
156
  data;run;%let tempds=%scan(&syslast,2,.);
158
157
  ods output Members=&tempds;
159
158
  proc datasets library=WORK memtype=data;
@@ -176,7 +175,7 @@
176
175
  put " ""&wt"" : {";
177
176
  put '"nlobs":' nlobs;
178
177
  put ',"nvars":' nvars;
179
- %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
178
+ %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10)
180
179
  data _null_; file &fref mod;put "}";
181
180
  %end;
182
181
  data _null_; file &fref mod;put "}";run;