Hello, I am learning SAS and trying to write a macro program that takes a file path as a macro parameter and a second parameter for the search term to be found in this file. However, I can't get it to work because I am getting the Error ERROR: The regular expression passed to the function PRXMATCH contains a syntax error. This is the code %macro matcher_prxmatch(path, search);
data prxmatch;
length pos count zeilen_nr 8 line $32767 regex pattern $100 lrecl 8 search $100;
infile "&path" lrecl=32767 truncover;
input line $varying32767. lrecl;
search="&search";
pattern = cats('/', search, '/i');
regex = prxparse(pattern);
if missing(regex) then do;
put "ERROR: Ungültiger regulärer Ausdruck.";
stop;
end;
zeilen_nr = _N_;
count = 0;
pos = prxmatch(regex, line);
if pos > 0 then do;
count + 1;
temp_line = substr(line, pos + 1);
do while (prxmatch(regex, temp_line) > 0);
count + 1;
temp_line = substr(temp_line, prxmatch(regex, temp_line) + 1);
end;
end;
output;
run;
proc print data=prxmatch;
var zeilen_nr count;
run;
%mend matcher_prxmatch;
%matcher_prxmatch(_____a.txt, SYS); Can someone explain to me why the error occurs?
... View more