From 078815e83e77290478fba8a4db05807d51d9422b Mon Sep 17 00:00:00 2001 From: munja Date: Wed, 2 Mar 2022 21:33:41 +0000 Subject: [PATCH] chore: stub --- base/mp_replace.sas | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 base/mp_replace.sas diff --git a/base/mp_replace.sas b/base/mp_replace.sas new file mode 100644 index 0000000..92825a2 --- /dev/null +++ b/base/mp_replace.sas @@ -0,0 +1,53 @@ +/** + @file + @brief Performs a text substitution on a file + @details Reads a file in byte by byte, performing text substiution where a + match is found. + + This macro can be used on files where lines are longer than 32767. + + If you are running a version of SAS that will allow the io package in LUA, you + can also use this macro: mp_gsubfile.sas + + Usage: + + %let file=%sysfunc(pathname(work))/file.txt; + %let str=replace/me; + %let rep=with/this; + data _null_; + file "&file"; + put 'blahblah'; + put "blahblah&str.blah"; + put 'blahblahblah'; + run; + %mp_replace(file=&file, patternvar=str, replacevar=rep) + data _null_; + infile "&file"; + input; + list; + run; + + @param file= (0) The file to perform the substitution on + @param patternvar= Macro variable NAME containing the string to search for + @param replacevar= Macro variable NAME containing the replacement string + @param outfile= (mp_rplce) The output fileref to contain the adjusted file. + +

SAS Macros

+ @li ml_gsubfile.sas + +

Related Macros

+ @li mp_gsubfile.test.sas + + @version 9.4 + @author Allan Bowe +**/ + +%macro mp_replace(file=0, + patternvar=, + replacevar=, + outref=mp_rplce +)/*/STORE SOURCE*/; + + %ml_gsubfile() + +%mend mp_replace;