@sasjs/core 4.31.0 → 4.31.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_abort.sas CHANGED
@@ -63,236 +63,236 @@
63
63
  , mode=REGULAR
64
64
  )/*/STORE SOURCE*/;
65
65
 
66
- %global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
67
- %local fref fid i;
66
+ %global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
67
+ %local fref fid i;
68
68
 
69
- %if not(%eval(%unquote(&iftrue))) %then %return;
69
+ %if not(%eval(%unquote(&iftrue))) %then %return;
70
70
 
71
- %put NOTE: /// mp_abort macro executing //;
72
- %if %length(&mac)>0 %then %put NOTE- called by &mac;
73
- %put NOTE - &msg;
71
+ %put NOTE: /// mp_abort macro executing //;
72
+ %if %length(&mac)>0 %then %put NOTE- called by &mac;
73
+ %put NOTE - &msg;
74
74
 
75
- %if %symexist(_SYSINCLUDEFILEDEVICE)
76
- /* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
77
- and %superq(SYSPROCESSNAME) ne %str(Compute Server)
75
+ %if %symexist(_SYSINCLUDEFILEDEVICE)
76
+ /* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
77
+ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
78
+ %then %do;
79
+ %if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
80
+ data &errds;
81
+ iftrue='1=1';
82
+ length mac $100 msg $5000;
83
+ mac=symget('mac');
84
+ msg=symget('msg');
85
+ run;
86
+ data _null_;
87
+ abort cancel FILE;
88
+ run;
89
+ %return;
90
+ %end;
91
+ %end;
92
+
93
+ /* Web App Context */
94
+ %if %symexist(_PROGRAM)
95
+ or %superq(SYSPROCESSNAME) = %str(Compute Server)
96
+ or &mode=INCLUDE
97
+ %then %do;
98
+ options obs=max replace mprint;
99
+ %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
78
100
  %then %do;
79
- %if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
80
- data &errds;
81
- iftrue='1=1';
82
- length mac $100 msg $5000;
83
- mac=symget('mac');
84
- msg=symget('msg');
85
- run;
101
+ options nosyntaxcheck;
102
+ %end;
103
+
104
+ %if &mode=INCLUDE %then %do;
105
+ %if %sysfunc(exist(&errds))=1 %then %do;
86
106
  data _null_;
87
- abort cancel FILE;
107
+ set &errds;
108
+ call symputx('iftrue',iftrue,'l');
109
+ call symputx('mac',mac,'l');
110
+ call symputx('msg',msg,'l');
111
+ putlog (_all_)(=);
88
112
  run;
113
+ %if (&iftrue)=0 %then %return;
114
+ %end;
115
+ %else %do;
116
+ %put &sysmacroname: No include errors found;
89
117
  %return;
90
118
  %end;
91
119
  %end;
92
120
 
93
- /* Web App Context */
94
- %if %symexist(_PROGRAM)
95
- or %superq(SYSPROCESSNAME) = %str(Compute Server)
96
- or &mode=INCLUDE
97
- %then %do;
98
- options obs=max replace mprint;
99
- %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
100
- %then %do;
101
- options nosyntaxcheck;
102
- %end;
103
-
104
- %if &mode=INCLUDE %then %do;
105
- %if %sysfunc(exist(&errds))=1 %then %do;
106
- data _null_;
107
- set &errds;
108
- call symputx('iftrue',iftrue,'l');
109
- call symputx('mac',mac,'l');
110
- call symputx('msg',msg,'l');
111
- putlog (_all_)(=);
112
- run;
113
- %if (&iftrue)=0 %then %return;
114
- %end;
115
- %else %do;
116
- %put &sysmacroname: No include errors found;
117
- %return;
118
- %end;
119
- %end;
120
-
121
- /* extract log errs / warns, if exist */
122
- %local logloc logline;
123
- %global logmsg; /* capture global messages */
124
- %if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
125
- %else %let logloc=%qsysfunc(getoption(LOG));
126
- proc printto log=log;run;
127
- %let logline=0;
128
- %if %length(&logloc)>0 %then %do;
121
+ /* extract log errs / warns, if exist */
122
+ %local logloc logline;
123
+ %global logmsg; /* capture global messages */
124
+ %if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
125
+ %else %let logloc=%qsysfunc(getoption(LOG));
126
+ proc printto log=log;run;
127
+ %let logline=0;
128
+ %if %length(&logloc)>0 %then %do;
129
+ data _null_;
130
+ infile &logloc lrecl=5000;
131
+ input; putlog _infile_;
132
+ i=1;
133
+ retain logonce 0;
134
+ if (
135
+ _infile_=:"%str(WARN)ING" or _infile_=:"%str(ERR)OR"
136
+ ) and logonce=0 then
137
+ do;
138
+ call symputx('logline',_n_);
139
+ logonce+1;
140
+ end;
141
+ run;
142
+ /* capture log including lines BEFORE the err */
143
+ %if &logline>0 %then %do;
129
144
  data _null_;
130
145
  infile &logloc lrecl=5000;
131
- input; putlog _infile_;
146
+ input;
132
147
  i=1;
133
- retain logonce 0;
134
- if (
135
- _infile_=:"%str(WARN)ING" or _infile_=:"%str(ERR)OR"
136
- ) and logonce=0 then
137
- do;
138
- call symputx('logline',_n_);
139
- logonce+1;
148
+ stoploop=0;
149
+ if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
150
+ call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
151
+ input;
152
+ i+1;
153
+ stoploop=1;
140
154
  end;
155
+ if stoploop=1 then stop;
141
156
  run;
142
- /* capture log including lines BEFORE the err */
143
- %if &logline>0 %then %do;
144
- data _null_;
145
- infile &logloc lrecl=5000;
146
- input;
147
- i=1;
148
- stoploop=0;
149
- if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
150
- call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
151
- input;
152
- i+1;
153
- stoploop=1;
154
- end;
155
- if stoploop=1 then stop;
156
- run;
157
- %end;
158
157
  %end;
158
+ %end;
159
159
 
160
- %if %symexist(SYS_JES_JOB_URI) %then %do;
161
- /* setup webout for Viya */
162
- options nobomfile;
163
- %if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
164
- filename _webout temp lrecl=999999 mod;
165
- %end;
166
- %else %do;
167
- filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
168
- name="_webout.json" lrecl=999999 mod;
169
- %end;
160
+ %if %symexist(SYS_JES_JOB_URI) %then %do;
161
+ /* setup webout for Viya */
162
+ options nobomfile;
163
+ %if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
164
+ filename _webout temp lrecl=999999 mod;
170
165
  %end;
171
- %else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
172
- options nobomfile;
173
- /* set up http header for SASjs Server */
174
- %let fid=%sysfunc(fopen(&fref,A));
175
- %if &fid=0 %then %do;
176
- %put %str(ERR)OR: %sysfunc(sysmsg());
177
- %return;
178
- %end;
179
- %let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
180
- %let rc=%sysfunc(fwrite(&fid));
181
- %let rc=%sysfunc(fclose(&fid));
182
- %let rc=%sysfunc(filename(&fref));
166
+ %else %do;
167
+ filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
168
+ name="_webout.json" lrecl=999999 mod;
183
169
  %end;
184
-
185
- /* send response in SASjs JSON format */
186
- data _null_;
187
- file _webout mod lrecl=32000 encoding='utf-8';
188
- length msg syswarningtext syserrortext $32767 mode $10 ;
189
- sasdatetime=datetime();
190
- msg=symget('msg');
191
- %if &logline>0 %then %do;
192
- msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
170
+ %end;
171
+ %else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
172
+ options nobomfile;
173
+ /* set up http header for SASjs Server */
174
+ %let fid=%sysfunc(fopen(&fref,A));
175
+ %if &fid=0 %then %do;
176
+ %put %str(ERR)OR: %sysfunc(sysmsg());
177
+ %return;
193
178
  %end;
194
- /* escape the escapes */
195
- msg=tranwrd(msg,'\','\\');
196
- /* escape the quotes */
197
- msg=tranwrd(msg,'"','\"');
198
- /* ditch the CRLFs as chrome complains */
199
- msg=compress(msg,,'kw');
200
- /* quote without quoting the quotes (which are escaped instead) */
201
- msg=cats('"',msg,'"');
202
- if symexist('_debug') then debug=quote(trim(symget('_debug')));
203
- else debug='""';
204
- if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
205
- if mode ne 'SASJS' then put '>>weboutBEGIN<<';
206
- put '{"SYSDATE" : "' "&SYSDATE" '"';
207
- put ',"SYSTIME" : "' "&SYSTIME" '"';
208
- put ',"sasjsAbort" : [{';
209
- put ' "MSG":' msg ;
210
- put ' ,"MAC": "' "&mac" '"}]';
211
- put ",""SYSUSERID"" : ""&sysuserid"" ";
212
- put ',"_DEBUG":' debug ;
213
- if symexist('_metauser') then do;
214
- _METAUSER=quote(trim(symget('_METAUSER')));
215
- put ",""_METAUSER"": " _METAUSER;
216
- _METAPERSON=quote(trim(symget('_METAPERSON')));
217
- put ',"_METAPERSON": ' _METAPERSON;
218
- end;
219
- if symexist('SYS_JES_JOB_URI') then do;
220
- SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
221
- put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
222
- end;
223
- _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
224
- put ',"_PROGRAM" : ' _PROGRAM ;
225
- put ",""SYSCC"" : ""&syscc"" ";
226
- syserrortext=quote(trim(symget('syserrortext')));
227
- put ",""SYSERRORTEXT"" : " syserrortext;
228
- put ",""SYSHOSTNAME"" : ""&syshostname"" ";
229
- put ",""SYSJOBID"" : ""&sysjobid"" ";
230
- put ",""SYSSCPL"" : ""&sysscpl"" ";
231
- put ",""SYSSITE"" : ""&syssite"" ";
232
- sysvlong=quote(trim(symget('sysvlong')));
233
- put ',"SYSVLONG" : ' sysvlong;
234
- syswarningtext=quote(trim(symget('syswarningtext')));
235
- put ",""SYSWARNINGTEXT"" : " syswarningtext;
236
- put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
237
- put "}" ;
238
- if mode ne 'SASJS' then put '>>weboutEND<<';
239
- run;
179
+ %let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
180
+ %let rc=%sysfunc(fwrite(&fid));
181
+ %let rc=%sysfunc(fclose(&fid));
182
+ %let rc=%sysfunc(filename(&fref));
183
+ %end;
240
184
 
241
- %put _all_;
185
+ /* send response in SASjs JSON format */
186
+ data _null_;
187
+ file _webout mod lrecl=32000 encoding='utf-8';
188
+ length msg syswarningtext syserrortext $32767 mode $10 ;
189
+ sasdatetime=datetime();
190
+ msg=symget('msg');
191
+ %if &logline>0 %then %do;
192
+ msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
193
+ %end;
194
+ /* escape the escapes */
195
+ msg=tranwrd(msg,'\','\\');
196
+ /* escape the quotes */
197
+ msg=tranwrd(msg,'"','\"');
198
+ /* ditch the CRLFs as chrome complains */
199
+ msg=compress(msg,,'kw');
200
+ /* quote without quoting the quotes (which are escaped instead) */
201
+ msg=cats('"',msg,'"');
202
+ if symexist('_debug') then debug=quote(trim(symget('_debug')));
203
+ else debug='""';
204
+ if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
205
+ if mode ne 'SASJS' then put '>>weboutBEGIN<<';
206
+ put '{"SYSDATE" : "' "&SYSDATE" '"';
207
+ put ',"SYSTIME" : "' "&SYSTIME" '"';
208
+ put ',"sasjsAbort" : [{';
209
+ put ' "MSG":' msg ;
210
+ put ' ,"MAC": "' "&mac" '"}]';
211
+ put ",""SYSUSERID"" : ""&sysuserid"" ";
212
+ put ',"_DEBUG":' debug ;
213
+ if symexist('_metauser') then do;
214
+ _METAUSER=quote(trim(symget('_METAUSER')));
215
+ put ",""_METAUSER"": " _METAUSER;
216
+ _METAPERSON=quote(trim(symget('_METAPERSON')));
217
+ put ',"_METAPERSON": ' _METAPERSON;
218
+ end;
219
+ if symexist('SYS_JES_JOB_URI') then do;
220
+ SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
221
+ put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
222
+ end;
223
+ _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
224
+ put ',"_PROGRAM" : ' _PROGRAM ;
225
+ put ",""SYSCC"" : ""&syscc"" ";
226
+ syserrortext=quote(trim(symget('syserrortext')));
227
+ put ",""SYSERRORTEXT"" : " syserrortext;
228
+ put ",""SYSHOSTNAME"" : ""&syshostname"" ";
229
+ put ",""SYSJOBID"" : ""&sysjobid"" ";
230
+ put ",""SYSSCPL"" : ""&sysscpl"" ";
231
+ put ",""SYSSITE"" : ""&syssite"" ";
232
+ sysvlong=quote(trim(symget('sysvlong')));
233
+ put ',"SYSVLONG" : ' sysvlong;
234
+ syswarningtext=quote(trim(symget('syswarningtext')));
235
+ put ",""SYSWARNINGTEXT"" : " syswarningtext;
236
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
237
+ put "}" ;
238
+ if mode ne 'SASJS' then put '>>weboutEND<<';
239
+ run;
242
240
 
243
- %if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
244
- data _null_;
245
- putlog 'stpsrvset program err and syscc';
246
- rc=stpsrvset('program error', 0);
247
- call symputx("syscc",0,"g");
248
- run;
249
- %if &sysscp=WIN
250
- and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
251
- and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
252
- /* skip approach (below) does not work in windows m6+ envs */
253
- endsas;
254
- %end;
255
- %else %do;
256
- /**
257
- * endsas kills 9.4m3 deployments by orphaning multibridges.
258
- * Abort variants are ungraceful (non zero return code)
259
- * This approach lets SAS run silently until the end :-)
260
- * Caution - fails when called within a %include within a macro
261
- * Use mp_include() to handle this.
262
- */
263
- filename skip temp;
264
- data _null_;
265
- file skip;
266
- put '%macro skip();';
267
- comment '%mend skip; -> fix lint ';
268
- put '%macro skippy();';
269
- comment '%mend skippy; -> fix lint ';
270
- run;
271
- %inc skip;
272
- %end;
241
+ %put _all_;
242
+
243
+ %if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
244
+ data _null_;
245
+ putlog 'stpsrvset program err and syscc';
246
+ rc=stpsrvset('program error', 0);
247
+ call symputx("syscc",0,"g");
248
+ run;
249
+ %if &sysscp=WIN
250
+ and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
251
+ and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
252
+ /* skip approach (below) does not work in windows m6+ envs */
253
+ endsas;
273
254
  %end;
274
- %else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
275
- /* endsas kills the session making it harder to fetch results */
255
+ %else %do;
256
+ /**
257
+ * endsas kills 9.4m3 deployments by orphaning multibridges.
258
+ * Abort variants are ungraceful (non zero return code)
259
+ * This approach lets SAS run silently until the end :-)
260
+ * Caution - fails when called within a %include within a macro
261
+ * Use mp_include() to handle this.
262
+ */
263
+ filename skip temp;
276
264
  data _null_;
277
- syswarningtext=symget('syswarningtext');
278
- syserrortext=symget('syserrortext');
279
- abort_msg=symget('msg');
280
- syscc=symget('syscc');
281
- sysuserid=symget('sysuserid');
282
- iftrue=symget('iftrue');
283
- put (_all_)(/=);
284
- call symputx('syscc',0);
285
- abort cancel nolist;
265
+ file skip;
266
+ put '%macro skip();';
267
+ comment '%mend skip; -> fix lint ';
268
+ put '%macro skippy();';
269
+ comment '%mend skippy; -> fix lint ';
286
270
  run;
271
+ %inc skip;
287
272
  %end;
288
- %else %do;
289
- %abort cancel;
290
- %end;
273
+ %end;
274
+ %else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
275
+ /* endsas kills the session making it harder to fetch results */
276
+ data _null_;
277
+ syswarningtext=symget('syswarningtext');
278
+ syserrortext=symget('syserrortext');
279
+ abort_msg=symget('msg');
280
+ syscc=symget('syscc');
281
+ sysuserid=symget('sysuserid');
282
+ iftrue=symget('iftrue');
283
+ put (_all_)(/=);
284
+ call symputx('syscc',0);
285
+ abort cancel nolist;
286
+ run;
291
287
  %end;
292
288
  %else %do;
293
- %put _all_;
294
289
  %abort cancel;
295
290
  %end;
291
+ %end;
292
+ %else %do;
293
+ %put _all_;
294
+ %abort cancel;
295
+ %end;
296
296
  %mend mp_abort;
297
297
 
298
298
  /** @endcond */
@@ -51,7 +51,7 @@
51
51
  @cond
52
52
  **/
53
53
 
54
- %macro mp_ds2cards(base_ds=, tgt_ds=
54
+ %macro mp_ds2cards(base_ds, tgt_ds=
55
55
  ,cards_file="%sysfunc(pathname(work))/cardgen.sas"
56
56
  ,maxobs=max
57
57
  ,random_sample=NO
@@ -254,6 +254,7 @@ data _null_;
254
254
  ;
255
255
  %end;
256
256
  put ";";
257
+ put 'missing a b c d e f g h i j k l m n o p q r s t u v w x y z _;';
257
258
  put "datalines4;";
258
259
  end;
259
260
  end;
@@ -263,7 +263,7 @@
263
263
  do i=1 to &numcols;
264
264
  name=quote(trim(symget(cats('name',i))));
265
265
  format=quote(trim(symget(cats('fmt',i))));
266
- label=quote(trim(symget(cats('label',i))));
266
+ label=quote(prxchange('s/\\/\\\\/',-1,trim(symget(cats('label',i)))));
267
267
  length=quote(trim(symget(cats('length',i))));
268
268
  type=quote(trim(symget(cats('typelong',i))));
269
269
  if i>1 then put "," @@;
@@ -296,7 +296,7 @@ data _null_;
296
296
  put ' do i=1 to &numcols; ';
297
297
  put ' name=quote(trim(symget(cats(''name'',i)))); ';
298
298
  put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
299
- put ' label=quote(trim(symget(cats(''label'',i)))); ';
299
+ put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
300
300
  put ' length=quote(trim(symget(cats(''length'',i)))); ';
301
301
  put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
302
302
  put ' if i>1 then put "," @@; ';
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.31.0"
38
+ "version": "4.31.3"
39
39
  }
@@ -298,7 +298,7 @@ data _null_;
298
298
  put ' do i=1 to &numcols; ';
299
299
  put ' name=quote(trim(symget(cats(''name'',i)))); ';
300
300
  put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
301
- put ' label=quote(trim(symget(cats(''label'',i)))); ';
301
+ put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
302
302
  put ' length=quote(trim(symget(cats(''length'',i)))); ';
303
303
  put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
304
304
  put ' if i>1 then put "," @@; ';
@@ -440,7 +440,7 @@ data _null_;
440
440
  put ' do i=1 to &numcols; ';
441
441
  put ' name=quote(trim(symget(cats(''name'',i)))); ';
442
442
  put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
443
- put ' label=quote(trim(symget(cats(''label'',i)))); ';
443
+ put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
444
444
  put ' length=quote(trim(symget(cats(''length'',i)))); ';
445
445
  put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
446
446
  put ' if i>1 then put "," @@; ';