85%local fref0 dttm ds1 outref;
86%let fref0=%mf_getuniquefileref();
87%let ds1=%mf_getuniquename(prefix=allchars);
88%let ds2=%mf_getuniquename(prefix=startmark);
90%
if &outfile=0 %then %let outfile=&infile;
92%mp_abort(iftrue= (%length(%superq(&matchvar))=0)
94 ,msg=%str(&matchvar is an empty variable)
98%let dttm=%sysfunc(datetime());
100filename &fref0 &infile lrecl=1 recfm=n;
105 input sourcechar $char1. @@;
106 format sourcechar hex2.;
112 length
string $ %length(%superq(&matchvar));
113 string =symget(
"&matchvar");
116 firstchar=char(
string,1);
117 findlen=lengthm(
string);
120 set &ds1 nobs=nobs point=_N_;
121 if sourcechar=firstchar then
do;
124 do point=_N_ to min(_N_ + findlen -1,nobs);
125 set &ds1 point=point;
126 if sourcechar=char(
string, pos) then s + 1;
131 if s=findlen then
do;
149 if "&matchpoint"=
'START' then
do;
150 if "&keep"=
'FIRST' then mp=start;
151 else if "&keep"=
'LAST' then mp=start-1;
153 else if "&matchpoint"=
'END' then
do;
154 if "&keep"=
'FIRST' then mp=stop+1;
155 else if "&keep"=
'LAST' then mp=stop;
158 call symputx(
'split',split,
'l');
159%
if &mdebug=1 %then %
do;
164%
if &split=0 %then %
do;
165 %put &sysmacroname: No match found in &infile
for string %superq(&matchvar);
170 file &outfile recfm=n;
172%
if &keep=FIRST %then %
do;
173 if _n_ ge &split then stop;
178 put sourcechar char1.;
181%
if &mdebug=0 %then %
do;
182 filename &fref0 clear;
186 infile &outfile lrecl=32767;
189 if _n_>200 then stop;
193%put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) seconds to run;