Hi Experts,
I have a list of phone number that including both Australia and oversea. the length of the phone number is undefined (can be anything)
I want to know if there is a smart way to find repeated pattern within any phone number without using regular expression.
for example: 04123123123 has repeated pattern 123123123
or 1212121212
has repeated pattern 1212121212
thanks
And why don't you want to use RegEx as that's the "ideal" syntax for anything pattern?
Do the repetitions have to be consecutive, or could this be a repeating pattern: 1234123
Could a repeating pattern contain as few as four digits (the original two, plus one repetition)?
Well, it's not really clear what "obvious" means in this context. So here's an example of how to do this for three-digit sets of digits:
length repeated3 $ 3;
if length(phoneno) >= 6 then do k=1 to length(phoneno)-5;
repeated3 = substr(phoneno, k);
if index( substr(phoneno, k+3), repeated3) then output;
end;
@gyambqt wrote:
Hi Patrick, I thought there might be some mathematic tricks like 12121212 is divisible by 10101 that able to solve the issue.
May be. But especially because this is about the very common case of phone number validation I'd go for RegEx. There should be a lot of RegEx published on the Internet and you won't have to "invent" everything from scratch. Just search a bit and use the one closest to your needs as a starting point.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.