BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lizzy28
Quartz | Level 8

Hi all,

 

Is there a way to identify phone numbers with all the same digits in one phone number? For example, the phone numbers like 1111111111, 5555555555, 9999999999.

 

Thanks a lot!

Lizzy

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @lizzy28,

 

Alternatively, you can use character functions. For example, the criterion

compress(t,first(t))=' '

should work for non-empty digit strings t (without hyphens, parentheses, leading blanks, etc.).

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Step 1: turn the phone number into a sequence of ten numeric (not character) single digit values.

Step 2: determine the min and max of these 10 single digit values, if the min=max then you have all the same digits


Example:

 

data have;
    phone_number='1111111111';
    array digit digit1-digit10;
    do i=1 to 10;
        digit(i)=input(substr(phone_number,i,1),1.);
    end;
    delta=max(of digit(*))-min(of digit(*));
    drop i;
run;

 

 

--
Paige Miller
FreelanceReinh
Jade | Level 19

Hi @lizzy28,

 

Alternatively, you can use character functions. For example, the criterion

compress(t,first(t))=' '

should work for non-empty digit strings t (without hyphens, parentheses, leading blanks, etc.).

mkeintz
PROC Star

If it's a 10 digit number then

if mod(phone_number,1111111111)=0 then flag=1;
else flag=0;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2415 views
  • 4 likes
  • 4 in conversation