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.
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.
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.