@sasjs/core 4.57.3 → 4.58.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 +11 -10
- package/base/mp_replace.sas +2 -1
- package/package.json +1 -1
- package/viya/mv_createfile.sas +30 -6
- package/viya/mv_createfolder.sas +1 -1
package/README.md
CHANGED
|
@@ -147,16 +147,17 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|
|
147
147
|
- macro names must be lowercase
|
|
148
148
|
- one macro per file
|
|
149
149
|
- prefixes:
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
150
|
+
- _mcf__: macro compiled functions (proc fcmp)
|
|
151
|
+
- _mddl__: macros containing DDL (Data Definition Language)
|
|
152
|
+
- _mf__: macro functions (can be used in open code).
|
|
153
|
+
- _mfv__: macro functions that work only in Viya
|
|
154
|
+
- _ml__: macros that are used to compile LUA modules
|
|
155
|
+
- _mm__: metadata macros (interface with the metadata server).
|
|
156
|
+
- _mmx__: macros that use metadata and are XCMD enabled (working on both windows and unix)
|
|
157
|
+
- _mp__: macro procedures (which generate sas code)
|
|
158
|
+
- _ms__: macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
|
159
|
+
- _mv__: macro procedures that will only work in Viya
|
|
160
|
+
- _mx__: macros that work on Viya, SAS 9 EBI and SASjs Server
|
|
160
161
|
- follow verb-noun convention
|
|
161
162
|
- unix style line endings (lf)
|
|
162
163
|
- individual lines should be no more than 80 characters long
|
package/base/mp_replace.sas
CHANGED
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
LUA, you can also use this macro: mp_gsubfile.sas
|
|
34
34
|
|
|
35
35
|
@param [in] infile The QUOTED path to the file on which to perform the
|
|
36
|
-
substitution
|
|
36
|
+
substitution. Note that you can extract the pathname from a fileref using
|
|
37
|
+
the pathname function, eg: `"%sysfunc(pathname(fref))"`;
|
|
37
38
|
@param [in] findvar= Macro variable NAME containing the string to search for
|
|
38
39
|
@param [in] replacevar= Macro variable NAME containing the replacement string
|
|
39
40
|
@param [out] outfile= (0) Optional QUOTED path to the adjusted output file (to
|
package/package.json
CHANGED
package/viya/mv_createfile.sas
CHANGED
|
@@ -17,6 +17,20 @@
|
|
|
17
17
|
run;
|
|
18
18
|
%mv_createfile(path=/Public/temp,name=newfile.txt,inref=myfile)
|
|
19
19
|
|
|
20
|
+
The macro also supports find & replace (used by the SASjs Streaming App
|
|
21
|
+
build program). This allows one string to be replaced by another at the
|
|
22
|
+
point at which the file is created. This is done by passing in the NAMES of
|
|
23
|
+
the macro variables containing the values to be swapped, eg:
|
|
24
|
+
|
|
25
|
+
filename fref temp;
|
|
26
|
+
data _null_;
|
|
27
|
+
file fref;
|
|
28
|
+
put 'whenever life gets you down, Mrs Brown..';
|
|
29
|
+
run;
|
|
30
|
+
%let f=Mrs Brown;
|
|
31
|
+
%let r=just remember that you're standing on a planet that's evolving;
|
|
32
|
+
%mv_createfile(path=/Public,name=life.md,inref=fref,fin,swap=f r)
|
|
33
|
+
|
|
20
34
|
|
|
21
35
|
@param [in] path= The parent (SAS Drive) folder in which to create the file
|
|
22
36
|
@param [in] name= The name of the file to be created
|
|
@@ -38,6 +52,8 @@
|
|
|
38
52
|
@li sas_services
|
|
39
53
|
@param [in] force= (YES) Will overwrite (delete / recreate) files by default.
|
|
40
54
|
Set to NO to abort if a file already exists in that location.
|
|
55
|
+
@param pin] swap= (0) Provide two macro variable NAMES that contain the values
|
|
56
|
+
to be swapped, eg swap=find replace (see also the example above)
|
|
41
57
|
@param [out] outds= (_null_) Output dataset with the uri of the new file
|
|
42
58
|
|
|
43
59
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
@@ -51,6 +67,7 @@
|
|
|
51
67
|
@li mfv_getpathuri.sas
|
|
52
68
|
@li mp_abort.sas
|
|
53
69
|
@li mp_base64copy.sas
|
|
70
|
+
@li mp_replace.sas
|
|
54
71
|
@li mv_createfolder.sas
|
|
55
72
|
|
|
56
73
|
<h4> Related Macros</h4>
|
|
@@ -69,6 +86,7 @@
|
|
|
69
86
|
,mdebug=0
|
|
70
87
|
,outds=_null_
|
|
71
88
|
,force=YES
|
|
89
|
+
,swap=0
|
|
72
90
|
);
|
|
73
91
|
%local dbg;
|
|
74
92
|
%if &mdebug=1 %then %do;
|
|
@@ -113,6 +131,12 @@
|
|
|
113
131
|
%end;
|
|
114
132
|
%else %put %str(ERR)OR: invalid value for intype: &intype;
|
|
115
133
|
|
|
134
|
+
%if "&swap" ne "0" %then %do;
|
|
135
|
+
%mp_replace("%sysfunc(pathname(&fref))"
|
|
136
|
+
,findvar=%scan(&swap,1,%str( ))
|
|
137
|
+
,replacevar=%scan(&swap,2,%str( ))
|
|
138
|
+
)
|
|
139
|
+
%end;
|
|
116
140
|
|
|
117
141
|
%if &mdebug=1 %then %do;
|
|
118
142
|
data _null_;
|
|
@@ -157,8 +181,10 @@ run;
|
|
|
157
181
|
%end;
|
|
158
182
|
"Accept"="*/*";
|
|
159
183
|
run;
|
|
160
|
-
%put &sysmacroname DELETE &base_uri&fileuri
|
|
161
|
-
|
|
184
|
+
%put &sysmacroname DELETE &base_uri&fileuri;
|
|
185
|
+
%if &SYS_PROCHTTP_STATUS_CODE ne 204 %then %do;
|
|
186
|
+
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
|
187
|
+
%end;
|
|
162
188
|
%end;
|
|
163
189
|
|
|
164
190
|
%local url mimetype ext;
|
|
@@ -205,7 +231,7 @@ run;
|
|
|
205
231
|
%local libref2;
|
|
206
232
|
%let libref2=%mf_getuniquelibref();
|
|
207
233
|
libname &libref2 JSON fileref=&fname1;
|
|
208
|
-
|
|
234
|
+
/* Grab the follow on link */
|
|
209
235
|
data &outds;
|
|
210
236
|
set &libref2..links end=last;
|
|
211
237
|
if rel='createChild' then do;
|
|
@@ -214,9 +240,7 @@ data &outds;
|
|
|
214
240
|
end;
|
|
215
241
|
run;
|
|
216
242
|
|
|
217
|
-
%put &sysmacroname:
|
|
218
|
-
%put &base_uri%mfv_getpathuri(&path/&name);%put;
|
|
243
|
+
%put &sysmacroname: &name created at %mfv_getpathuri(&path/&name);%put;
|
|
219
244
|
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
|
220
|
-
%put &sysmacroname:;
|
|
221
245
|
|
|
222
246
|
%mend mv_createfile;
|
package/viya/mv_createfolder.sas
CHANGED