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

 

I am trying to find data that is 7 digits long and start with the number 4. 

 

data want;
if not prxId then prxId + prxParse("/\d{7}\/");
set CV_misscr14;
start = 1;
stop = length(aj_text);
call prxNext(prxID, start, stop, aj_text, pos, len);
do while (pos > 0);
    cmaenum = input(prxPosn(prxId, 1, aj_text), best.);
    output;
    call prxNext(prxID, start, stop, aj_text, pos, len);
    end;
/*drop prxId start stop pos len;*/
run;

What do I need to change here for it to search for that?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Kiteulf,

 

Your DO loop suggests that you anticipate the possibility of more than one match per value of aj_text. In this case just correct the regular expression to 

/4\d{6}/

and the second argument of the PRXPOSN function to 0

 

Then from, say,

aj_text='3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706'

you would obtain

cmaenum

4159265
4626433
4197169
4944592
4062862
4825342

View solution in original post

2 REPLIES 2
Ksharp
Super User
data have;
input x $10.;
if prxmatch('/^4\d{6}$/',strip(x)) then found=1;
cards;
1234567890
3232ywrer67
4wewe786834
4586888
45678213
;
FreelanceReinh
Jade | Level 19

Hi @Kiteulf,

 

Your DO loop suggests that you anticipate the possibility of more than one match per value of aj_text. In this case just correct the regular expression to 

/4\d{6}/

and the second argument of the PRXPOSN function to 0

 

Then from, say,

aj_text='3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706'

you would obtain

cmaenum

4159265
4626433
4197169
4944592
4062862
4825342

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 771 views
  • 1 like
  • 3 in conversation