1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-03 15:40:05 +00:00

feat: adding mp_gsubfile.sas - a SAS macro that uses Lua to perform a full text find and replace of an entire file. Not restricted by number of characters (only memory). IIncludes a test.

This commit is contained in:
Allan Bowe
2021-09-14 16:07:12 +01:00
parent 52bf6019fd
commit d47a369cdf
5 changed files with 253 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/**
@file
@brief Testing mp_gsubfile.sas macro
<h4> SAS Macros </h4>
@li mp_gsubfile.sas
@li mp_assert.sas
**/
/**
* test 1 - simple replace
*/
%global str1;
%let file=%sysfunc(pathname(work))/file.txt;
%let pat=replace/me;
%let str=with/this;
data _null_;
file "&file";
put "&pat";
run;
%mp_gsubfile(file=&file, patternvar=pat, replacevar=str)
data _null_;
infile "&file";
input;
call symputx('str1',_infile_);
run;
%mp_assert(
iftrue=("&str1"="&str"),
desc=Check that simple replacement was successful,
outds=work.test_results
)