@sasjs/core 4.66.4 → 4.67.1

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/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "maintainers": [
36
36
  "https://sasapps.io"
37
37
  ],
38
- "version": "4.66.4"
38
+ "version": "4.67.1"
39
39
  }
@@ -121,7 +121,7 @@
121
121
  @li mf_nobs.sas
122
122
  @li mp_abort.sas
123
123
  @li mf_getplatform.sas
124
- @li mf_getuniquefileref.sas
124
+ @li mf_getvarlist.sas
125
125
  @li mf_existvarlist.sas
126
126
  @li mv_jobwaitfor.sas
127
127
  @li mv_jobexecute.sas
@@ -234,14 +234,12 @@ data _null_;
234
234
  if last then call symputx('flowcnt',cnt,'l');
235
235
  run;
236
236
 
237
- /* prepare temporary datasets and frefs */
238
- %local fid jid jds jjson jdsapp jdsrunning jdswaitfor jfref;
237
+ /* prepare temporary datasets */
238
+ %local fid jid jds jdsapp jdsrunning jdswaitfor;
239
239
  data;run;%let jds=&syslast;
240
- data;run;%let jjson=&syslast;
241
240
  data;run;%let jdsapp=&syslast;
242
241
  data;run;%let jdsrunning=&syslast;
243
242
  data;run;%let jdswaitfor=&syslast;
244
- %let jfref=%mf_getuniquefileref();
245
243
 
246
244
  /* start loop */
247
245
  %do fid=1 %to &flowcnt;
@@ -259,23 +257,39 @@ data;run;%let jdswaitfor=&syslast;
259
257
  &dbg. if _n_= 1 then putlog "Loop &fid";
260
258
  &dbg. putlog (_all_)(=);
261
259
  run;
260
+ /* build list of char and num vars in json format */
261
+ /* Viya 2026 expects all values to be strings */
262
+ %local nvars cvars ii _vnm;
263
+ %let cvars=%mf_getvarlist(&jds,typefilter=C);
264
+ %let nvars=%mf_getvarlist(&jds,typefilter=N);
262
265
  %put exporting job variables in json format;
263
266
  %do jid=1 %to &jcnt;
264
- data &jjson;
265
- set &jds;
266
- if _n_=&jid then do;
267
- output;
268
- stop;
269
- end;
270
- run;
271
- proc json out=&jfref;
272
- export &jjson / nosastags fmtnumeric;
273
- run;
274
267
  data _null_;
275
- infile &jfref lrecl=32767;
276
- input;
277
- jparams=cats('jparams',symget('jid'));
278
- call symputx(jparams,substr(_infile_,3,length(_infile_)-4));
268
+ set &jds;
269
+ if _n_=&jid;
270
+ length _param $32767;
271
+ _param='';
272
+ %if %length(&cvars)>0 %then %do ii=1 %to %sysfunc(countw(&cvars,%str( )));
273
+ %let _vnm=%scan(&cvars,&ii,%str( ));
274
+ if _param ne '' then _param=cats(_param,',');
275
+ _param=cats(_param,'"'
276
+ ,"%lowcase(&_vnm)"
277
+ ,'":'
278
+ ,quote(trim(&_vnm))
279
+ );
280
+ %end;
281
+ %if %length(&nvars)>0 %then %do ii=1 %to %sysfunc(countw(&nvars,%str( )));
282
+ %let _vnm=%scan(&nvars,&ii,%str( ));
283
+ if _param ne '' then _param=cats(_param,',');
284
+ _param=cats(_param,'"'
285
+ ,"%lowcase(&_vnm)"
286
+ ,'":"'
287
+ ,strip(put(&_vnm,best32.))
288
+ ,'"'
289
+ );
290
+ %end;
291
+ call symputx(cats('jparams',&jid),_param,'l');
292
+ stop;
279
293
  run;
280
294
  %local jobuid&jid;
281
295
  %let jobuid&jid=0; /* used in next loop */
@@ -320,6 +334,7 @@ data;run;%let jdswaitfor=&syslast;
320
334
  ,paramstring=%superq(jparams&jid)
321
335
  ,outds=&jdsapp
322
336
  ,contextname=&&context&jid
337
+ ,mdebug=&mdebug
323
338
  )
324
339
  data &jdsapp;
325
340
  format jobparams $32767.;
@@ -0,0 +1,149 @@
1
+ /**
2
+ @file
3
+ @brief Appends a text file to a SASjs Stored Program, Viya SAS program, or
4
+ SAS 9 Stored Process
5
+ @details Extracts the source code from a SASjs Stored Program, Viya SAS
6
+ program (file in SAS Drive), or SAS 9 Stored Process, appends the contents
7
+ of a provided text file, then deletes and recreates the target item with the
8
+ combined content.
9
+
10
+ This is useful for dynamically modifying deployed programs, for example to
11
+ add test-specific configuration or runtime settings.
12
+
13
+ Usage:
14
+
15
+ %* compile macros ;
16
+ filename mc url
17
+ "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
18
+ %inc mc;
19
+
20
+ %* write some content to append;
21
+ filename append temp;
22
+ data _null_;
23
+ file append;
24
+ put "libname mylib '/some/path';";
25
+ run;
26
+
27
+ %* append to existing program;
28
+ %mx_append2pgm(/Public/app/common/settings, inref=append)
29
+
30
+ @param [in] loc The full path to the Viya SAS program, SAS 9 Stored Process,
31
+ or SASjs Stored Program in Drive or Metadata, WITHOUT the .sas extension
32
+ (SASjs only)
33
+ @param [in] inref= (0) Fileref pointing to the content to be appended to the
34
+ target program.
35
+ @param [in] mdebug= (0) Set to 1 to show debug messages in the log
36
+
37
+ <h4> SAS Macros </h4>
38
+ @li mf_getplatform.sas
39
+ @li mf_getuniquefileref.sas
40
+ @li mm_createstp.sas
41
+ @li mm_deletestp.sas
42
+ @li mm_getstpcode.sas
43
+ @li ms_createfile.sas
44
+ @li ms_deletefile.sas
45
+ @li mv_createfile.sas
46
+ @li mv_deletefoldermember.sas
47
+ @li mx_getcode.sas
48
+
49
+ <h4> Related Macros </h4>
50
+ @li mx_append2pgm.test.sas
51
+ @li mx_getcode.sas
52
+ @li mx_createjob.sas
53
+
54
+ @author Allan Bowe
55
+
56
+ **/
57
+
58
+ %macro mx_append2pgm(loc
59
+ ,inref=0
60
+ ,mdebug=0
61
+ )/*/STORE SOURCE*/;
62
+
63
+ %local platform name shortloc coderef combref work tmpfile viyaref;
64
+ %let platform=%mf_getplatform();
65
+
66
+ %if &mdebug=1 %then %do;
67
+ %put &sysmacroname entry vars:;
68
+ %put _local_;
69
+ %end;
70
+ %if &syscc ne 0 %then %do;
71
+ %put syscc=&syscc - &sysmacroname will not execute in this state;
72
+ %return;
73
+ %end;
74
+
75
+ /* extract name & path from loc */
76
+ data _null_;
77
+ length name shortloc $500;
78
+ loc=symget('loc');
79
+ name=scan(loc,-1,'/');
80
+ shortloc=substr(loc,1,length(loc)-length(name)-1);
81
+ call symputx('name',name,'l');
82
+ call symputx('shortloc',shortloc,'l');
83
+ run;
84
+
85
+ /* create a combined fileref with original + appended content */
86
+ %let combref=%mf_getuniquefileref();
87
+ %let work=%sysfunc(pathname(work));
88
+ %let tmpfile=&combref..sas;
89
+ filename &combref "&work/&tmpfile" lrecl=32000;
90
+
91
+ %if &platform=SASVIYA %then %do;
92
+ /* On Viya, read the SAS program file from SAS Drive using filesrvc */
93
+ %let viyaref=%mf_getuniquefileref();
94
+ filename &viyaref filesrvc folderpath="&shortloc";
95
+ data _null_;
96
+ file &combref lrecl=32000 termstr=crlf;
97
+ infile &viyaref("&name..sas") lrecl=32000 end=last;
98
+ input;
99
+ put _infile_;
100
+ run;
101
+ filename &viyaref clear;
102
+ %symdel _FILESRVC_&viyaref._URI;
103
+ %end;
104
+ %else %do;
105
+ /* For SAS9 and SASJS, use mx_getcode */
106
+ %let coderef=%mf_getuniquefileref();
107
+ %mx_getcode(&loc, outref=&coderef)
108
+ data _null_;
109
+ file &combref lrecl=32000 termstr=crlf;
110
+ infile &coderef lrecl=32000 end=last;
111
+ input;
112
+ put _infile_;
113
+ run;
114
+ filename &coderef clear;
115
+ %end;
116
+
117
+ /* append the new content */
118
+ data _null_;
119
+ file &combref lrecl=32000 termstr=crlf mod;
120
+ infile &inref lrecl=32000;
121
+ input;
122
+ put _infile_;
123
+ run;
124
+
125
+ /* delete and recreate the target item */
126
+ %if &platform=SASJS %then %do;
127
+ %ms_deletefile(&loc..sas)
128
+ %ms_createfile(&loc..sas, inref=&combref, mdebug=&mdebug)
129
+ %end;
130
+ %else %if &platform=SASVIYA %then %do;
131
+ %mv_deletefoldermember(path=&shortloc, name=&name..sas, contenttype=file)
132
+ %mv_createfile(path=&shortloc, name=&name..sas, inref=&combref)
133
+ %end;
134
+ %else %do;
135
+ /* SAS 9 */
136
+ %mm_deletestp(target=&loc)
137
+ %mm_createstp(stpname=&name
138
+ ,filename=&tmpfile
139
+ ,directory=&work
140
+ ,tree=&shortloc
141
+ ,stptype=2
142
+ ,mDebug=&mdebug
143
+ ,minify=NO
144
+ )
145
+ %end;
146
+
147
+ filename &combref clear;
148
+
149
+ %mend mx_append2pgm;