Hi SAS community,
I have this scenario, where I need to extract account numbers from a string and it is messy and need help to fix it.
eg:
data have;
input accountnumber $50.;
cards;
pcg1234500008765CheckingPCG000006878siim
OAK000000345697000000CHECK
MMTAYL8202206ERRA23124999GIG
YYY2356543ach78Y34????
;
run;
WANT
1234500008765CheckingPCG000006878
000000345697000000
8202206ERRA23124999
2356543ach78Y34
I tried to use anydigit and substring function to start the right number, but I can't finish how to substring to get to the last digit?
Can someone help?
thanks
I can't use the compress function as it eliminates even the letters in between account number. some account numbers are masked with letters for security reasons. So, this might not be an option.
Thanks for responding.
Rules for why in
pcg1234500008765CheckingPCG000006878siim
you remove the first pcg but keep the second PCG are going to complicate this a lot.
Do you have any documentation about the components of that obnoxious string from the source?
That you can share?
Ballardw,
This is just dummy data that I created. The real production data is messy. I just observed some pattern and posted it. I do need to extract the starting numerical digit (along with any letters are there in between) and ending numerical digit. How could I get it? I could get the starting numerical value for all the values, but to get the entrire string till the last number digit is the real challenge. Could someone help me in that please?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.