I have searched and not found the answer, hoping someone here can assist. The error message below is displayed in the SAS Log when I attempt to use the "/g" modifier in a prxparse statement.
ERROR: Regular expression option "g" in "/ABC-\d{4}-\d{4}/g" is not supported.
ERROR: The regular expression passed to the function PRXPARSE contains a syntax error.
It appears that "/g" is a valid PERL modifier however SAS does not support this modifier, so I need a solution that will allow me to find the patter above in a string and return all instances matched from the string, an example of the string is below.
"Technology Affected: program name here ABC ID: ABC-5102-2408 Record #:1596081 First publish date: 6/1/1969" or alternately
"Technology Affected: program name here ABC ID: ABC-5102-2408 ABC-9876-1234 ABC-7654-3456 ABC-0192-3948 Record #:1596081 First publish date: 6/1/1969"
Thank you in advance!
And there is a little error in your PRX .
data _null_;
str="Technology Affected: program name here ABC ID: ABC-5102-2408 ABC-9876-1234 ABC-7654-3456 ABC-0192-3948 Record #:1596081 First publish date: 6/1/1969";
pid=prxparse('/ABC\-\d{4}\-\d{4}/o');
start=1;
stop=length(str);
call prxnext(pid,start,stop,str,p,l);
do while(p>0);
temp=substr(str,p,l);
call prxnext(pid,start,stop,str,p,l);
put temp=;
end;
run;
What is modifier g supposed to mean?
According to the help text on https://regex101.com/ the definition is:
"g modifier: global. All matches (don't return on first match)".
When i test my PERL expression on this site using the "g" modifier I get matches for all instances in the text example.
Look at CALL PRXNEXT() to retrieve multiple matches.
SAS does not suport all perl modifiers. The only suffixes supported by sas are i x s m and o.
The documentation is wrong about what is supported though. For example \G is a supported assertion.
A full list of supported syntax together with examples is shown in
https://www.amazon.com/High-Performance-SAS-Coding-Christian-Graffeuille/dp/1512397490
And there is a little error in your PRX .
data _null_;
str="Technology Affected: program name here ABC ID: ABC-5102-2408 ABC-9876-1234 ABC-7654-3456 ABC-0192-3948 Record #:1596081 First publish date: 6/1/1969";
pid=prxparse('/ABC\-\d{4}\-\d{4}/o');
start=1;
stop=length(str);
call prxnext(pid,start,stop,str,p,l);
do while(p>0);
temp=substr(str,p,l);
call prxnext(pid,start,stop,str,p,l);
put temp=;
end;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: