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?
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
data have;
input x $10.;
if prxmatch('/^4\d{6}$/',strip(x)) then found=1;
cards;
1234567890
3232ywrer67
4wewe786834
4586888
45678213
;
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.