The points raised by @RW9 will need to be addressed, but as the question is presented the following might help. /* set up data */
data have;
infile datalines truncover;
input have $char70.;
input replace $char30.;
datalines4;
Benchmark indices registered recovery from the day's low point.
(old="low", new="high")
Completes inspection at Factory
(old="at", new="in")
Patient; status; cardiac arrest
(old=";",new=',')
That"s ok
(old='"',new="'")
This 'dataline' uses quotes
(old="'",new='"')
;;;;
data want;
set have;
length find_str repl_str $ 8;
/* get 'old' string and remove quotes */
find_str = strip(tranwrd(scanq(replace,1,','),'(old=',''));
find_str = dequote(find_str);
/* get 'new' string and remove quotes */
repl_str = strip(tranwrd(scanq(replace,2,','),'new=',''));
repl_str = substr(repl_str,1,length(repl_str) - 1);
repl_str = dequote(repl_str);
/* perform replace */
want = tranwrd(have,strip(find_str),strip(repl_str));
run;
... View more