@sasjs/core 4.57.4 → 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.
@@ -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
@@ -32,5 +32,5 @@
32
32
  "lint": "npx @sasjs/cli lint",
33
33
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
34
34
  },
35
- "version": "4.57.4"
35
+ "version": "4.58.0"
36
36
  }
@@ -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_;