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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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