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:
33
tests/crossplatform/mp_gsubfile.test.sas
Normal file
33
tests/crossplatform/mp_gsubfile.test.sas
Normal 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
|
||||
)
|
||||
Reference in New Issue
Block a user