I'm looking to extract IBAN numbers from some SWIFT data I have, but my PRXMATCH function doesn't seem to be working, does anyone know why?
An example of the text field I'm searching in would be:
LV05AIZK1234567891234 COMPANY NAME ADDRESS
In order to find the starting character for the match to use in a substring extract, I'm using:
PRXMATCH('/\LV\d{2}\D{4}\d{13}\s/', COLUMN)
This looks right to me but I keep getting a result of zero where I can see this IBAN form in the data.
This seemes to work 🙂
data one;
length iban $32 column $200;
column = 'One IBAN Number: LV05AIZK1234567891234 COMPANY NAME ADDRESS';
pos = PRXMATCH('/LV\d{2}\D{4}\d{13}/', COLUMN);
run;
I removed the first \ and the trailing \s.....
//Fredrik
Would not scan(string,1," ") not work?
That's a much neater solution for this particular problem thanks. For instances where the IBAN can potentially be anywhere in the string, can you think what's wrong the the PRXPARSE statement?
Well, I am not familiar with Perl so much, so will let others comment on that. If it always starts with "LV" and length 21 which your regex seems to indicate then:
want=substr(thestring,index(thestring,"LV"),21);
So find LV in the string, and then substr out 21 characters from there.
Perfect, thanks
This seemes to work 🙂
data one;
length iban $32 column $200;
column = 'One IBAN Number: LV05AIZK1234567891234 COMPANY NAME ADDRESS';
pos = PRXMATCH('/LV\d{2}\D{4}\d{13}/', COLUMN);
run;
I removed the first \ and the trailing \s.....
//Fredrik
Yes, this works now thanks
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.