Macros for SAS Application Developers
https://github.com/sasjs/core
Toggle main menu visibility
Home
File List
▼
@sasjs/core
Macro Core
▼
File List
▼
base
mf_abort.sas
mf_dedup.sas
mf_deletefile.sas
mf_existds.sas
mf_existfeature.sas
mf_existfileref.sas
mf_existfunction.sas
mf_existvar.sas
mf_existvarlist.sas
mf_fmtdttm.sas
mf_getapploc.sas
mf_getattrc.sas
mf_getattrn.sas
mf_getengine.sas
mf_getfilesize.sas
mf_getfmtlist.sas
mf_getfmtname.sas
mf_getgitbranch.sas
mf_getkeyvalue.sas
mf_getplatform.sas
mf_getquotedstr.sas
mf_getschema.sas
mf_getuniquefileref.sas
mf_getuniquelibref.sas
mf_getuniquename.sas
mf_getuser.sas
mf_getvalue.sas
mf_getvarcount.sas
mf_getvarformat.sas
mf_getvarlen.sas
mf_getvarlist.sas
mf_getvarnum.sas
mf_getvartype.sas
mf_getxengine.sas
mf_increment.sas
mf_isblank.sas
mf_isdir.sas
mf_isint.sas
mf_islibds.sas
mf_loc.sas
mf_mkdir.sas
mf_mval.sas
mf_nobs.sas
mf_readfile.sas
mf_trimstr.sas
mf_uid.sas
mf_verifymacvars.sas
mf_wordsinstr1andstr2.sas
mf_wordsinstr1butnotstr2.sas
mf_writefile.sas
mp_abort.sas
mp_aligndecimal.sas
mp_appendfile.sas
mp_applyformats.sas
mp_assert.sas
mp_assertcols.sas
mp_assertcolvals.sas
mp_assertdsobs.sas
mp_assertscope.sas
mp_base64copy.sas
mp_binarycopy.sas
mp_chop.sas
mp_cleancsv.sas
mp_cntlout.sas
mp_copyfolder.sas
mp_coretable.sas
mp_createconstraints.sas
mp_createwebservice.sas
mp_csv2ds.sas
mp_deleteconstraints.sas
mp_deletefolder.sas
mp_dictionary.sas
mp_dirlist.sas
mp_distinctfmtvalues.sas
mp_dropmembers.sas
mp_ds2cards.sas
mp_ds2csv.sas
mp_ds2ddl.sas
mp_ds2fmtds.sas
mp_ds2inserts.sas
mp_ds2md.sas
mp_ds2squeeze.sas
mp_dsmeta.sas
mp_filtercheck.sas
mp_filtergenerate.sas
mp_filterstore.sas
mp_filtervalidate.sas
mp_getcols.sas
mp_getconstraints.sas
mp_getdbml.sas
mp_getddl.sas
mp_getformats.sas
mp_getmaxvarlengths.sas
mp_getpk.sas
mp_gitadd.sas
mp_gitlog.sas
mp_gitreleaseinfo.sas
mp_gitstatus.sas
mp_gsubfile.sas
mp_guesspk.sas
mp_hashdataset.sas
mp_hashdirectory.sas
mp_include.sas
mp_init.sas
mp_jsonout.sas
mp_lib2cards.sas
mp_lib2inserts.sas
mp_loadformat.sas
mp_lockanytable.sas
mp_lockfilecheck.sas
mp_makedata.sas
mp_md5.sas
mp_perflog.sas
mp_prevobs.sas
mp_recursivejoin.sas
mp_replace.sas
mp_reseterror.sas
mp_resetoption.sas
mp_retainedkey.sas
mp_runddl.sas
mp_searchcols.sas
mp_searchdata.sas
mp_setkeyvalue.sas
mp_sortinplace.sas
mp_stackdiffs.sas
mp_storediffs.sas
mp_stprequests.sas
mp_streamfile.sas
mp_stripdiffs.sas
mp_testjob.sas
mp_testservice.sas
mp_testwritespeedlibrary.sas
mp_tree.sas
mp_unzip.sas
mp_updatevarlength.sas
mp_validatecol.sas
mp_wait4file.sas
mp_webin.sas
mp_zip.sas
►
ddl
►
fcmp
►
lua
►
meta
►
metax
►
server
►
tests
►
viya
►
xplatform
•
All
Files
Pages
Loading...
Searching...
No Matches
mp_gsubfile.sas
Go to the documentation of this file.
1
/**
2
@file
3
@brief Performs a text substitution on a file
4
@details Makes use of the GSUB function in LUA to perform a text substitution
5
in a file - either in-place, or writing to a new location. The benefit of
6
using LUA is that the entire file can be loaded into a single variable,
7
thereby side stepping the 32767 character limit in a data step.
8
9
Usage:
10
11
%let file=%sysfunc(pathname(work))/file.txt;
12
%let str=replace/me;
13
%let rep=with/this;
14
data _null_;
15
file "&file";
16
put "&str";
17
run;
18
%mp_gsubfile(file=&file, patternvar=str, replacevar=rep)
19
data _null_;
20
infile "&file";
21
input;
22
list;
23
run;
24
25
@param [in] file= (0) The file to perform the substitution on
26
@param [in] patternvar= A macro variable containing the Lua
27
[pattern](https://www.lua.org/pil/20.2.html) to search for. Due to the use
28
of special (magic) characters in Lua patterns, it is safer to pass the NAME
29
of the macro variable containing the string, rather than the value itself.
30
@param [in] replacevar= ()
31
The name of the macro variable containing the replacement _string_.
32
@param [out] outfile= (0) The file to write the output to.
33
If zero, then the file is overwritten in-place.
34
35
<h4> SAS Macros </h4>
36
@li ml_gsubfile.sas
37
38
<h4> Related Macros </h4>
39
@li mp_gsubfile.test.sas
40
41
@version 9.4
42
@author Allan Bowe
43
**/
44
45
%macro mp_gsubfile(file=0,
46
patternvar=,
47
replacevar=,
48
outfile=0
49
)
/*/STORE SOURCE*/
;
50
51
%
if
"%substr(&sysver.XX,1,4)"
=
"V.04"
%then %
do
;
52
%put %str(ERR)OR: Viya 4 does not support the IO library in lua;
53
%
return
;
54
%end;
55
56
%ml_gsubfile()
57
58
%mend mp_gsubfile;
base
mp_gsubfile.sas
Generated by
1.12.0
For more information visit the
Macro Core library
.