- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
--------------------------