Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRXPARSE, is it possible to combine selections?

Status
Not open for further replies.

wphupkes

Technical User
Jul 1, 2008
22
0
0
NL
All,

I've got a datastep in which I extract a number from a string. But... The strings are changing from time to time, but only the first part before the word "Incident" (sometime there appear some numbers, but I don't need those). So what I can do, is make 2 datasteps with the statements:

PATTERN = PRXPARSE("/^Incident/"); --> start from this word

PATTERN = PRXPARSE("/\d\d\d\d\d?/"); --> collect the desired number

But it must be able to combine these statements, I think? Saves a lot of time and space! :) Thanks in advance!
 
Got it!

DATA work.test2 ;
set test;
RETAIN regExp ;
IF _N_=1 THEN regExp = PRXPARSE("/(I|i)ncident\s(\d+).?/") ;
IF PRXMATCH(regExp, text) THEN number = PRXPOSN(regExp, 2,text) ;
run;
 
Well done Duckman! Thanks for posting the answer as well. PRXPARSE is some pretty serious code! I've used it a couple of times, and it's always a trial and error thing for me.
Nice work.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top