Hi, I have a set of 3 regular expressions that I must apply to 2 different text variables. In order to be able to reuse the code, I decided to store the regular expressions and perform the matching inside a FCMP block: proc fcmp outlib=myfuncz.turnout43ge.pdprx;
subroutine pdprx(ps_code$, pd_num, pd_num_sfx$, split_sfx$);
outargs pd_num, pd_num_sfx, split_sfx;
re = prxparse("/^(\d+)$|^(\d+-\d)$|^(\d+[A-Z]+)$/");
re2 = prxparse("/^(\d+)-(\d)$/");
re3 = prxparse("/^(\d+)([A-Z]+)$/");
pd_num=.;
pd_num_sfx="";
split_sfx="";
if prxmatch(re, ps_code) then do;
wc = prxparen(re);
select (wc);
when (1) pd_num=input(ps_code, best32.);
when (2)
do;
dummy = prxmatch(re2, ps_code);
call prxposn(re2, 1, pos, len);
pd_num=input(substr(ps_code, pos, len), best32.);
call prxposn(re2, 2, pos, len);
pd_num_sfx=substr(ps_code, pos, len);
end;
when (3)
do;
dummy = prxmatch(re3, trim(ps_code));
call prxposn(re3, 1, pos, len);
pd_num=input(substr(ps_code, pos, len), best32.);
call prxposn(re3, 2, pos, len);
split_sfx=substr(ps_code, pos, len);
end;
otherwise;
end;
end;
endsub;
quit; Unfortunately, this increases processing time in an unacceptable way: it now takes 10 minutes to process 75,000 records, instead of barely a minute if the the processing is done in the DATA step. I suppose that what is happening is that the patterns are being recompiled each time the FCMP function is called, which explains the slowdown. My question is the following: is there a way to cache the compiled patterns, so that I can still use the FCMP method? I could always write a macro to apply to the DATA step, but I see it as an inferior solution. Thanks!
... View more