BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GriffT
Obsidian | Level 7

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

What is modifier g supposed to  mean?

PG
GriffT
Obsidian | Level 7

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.

PGStats
Opal | Level 21

Look at CALL PRXNEXT() to retrieve multiple matches.

PG
ChrisNZ
Tourmaline | Level 20

 

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

 

 

Ksharp
Super User

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;
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2360 views
  • 4 likes
  • 4 in conversation