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

Hi,

I am looking here to get any Digit is continuously repeated  more than 6 times from Security_No.

Sl_NoSecurity_No
1111111111112
2989898989898
3111111111111
4910000000000
5999999999990
6128390203040
7127777777771
8739349340595
9634995038404

Thanks in Advance....!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

data have;

input Sl_No Security_No : $20.;

cards;

1 111111111112

2 989898989898

3 111111111111

4 910000000000

5 999999999990

6 128390203040

7 127777777771

8 739349340595

9 634995038404

;

run;

data want;

set have;

if prxmatch('/0{6,}|1{6,}|2{6,}|3{6,}|4{6,}|5{6,}|6{6,}|7{6,}|8{6,}|9{6,}/o',Security_No);

run;

Xia Keshan

View solution in original post

3 REPLIES 3
Ksharp
Super User

data have;

input Sl_No Security_No : $20.;

cards;

1 111111111112

2 989898989898

3 111111111111

4 910000000000

5 999999999990

6 128390203040

7 127777777771

8 739349340595

9 634995038404

;

run;

data want;

set have;

if prxmatch('/0{6,}|1{6,}|2{6,}|3{6,}|4{6,}|5{6,}|6{6,}|7{6,}|8{6,}|9{6,}/o',Security_No);

run;

Xia Keshan

FriedEgg
SAS Employee

Here is an alternative to using regular expression.

data foo;

input Sl_No Security_No : $12.;

do rept_int=0 to 9 while (_n_>0);

   if find(Security_No, repeat(put(rept_int,1.),5)) then do;

      _n_=0;

      output;

      end;

   end;

cards;

1 111111111112

2 989898989898

3 111111111111

4 910000000000

5 999999999990

6 128390203040

7 127777777771

8 739349340595

9 634995038404

;

run;

sas_lak
Quartz | Level 8

Thank you...!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 853 views
  • 3 likes
  • 3 in conversation