Hi!
Can anybody help me please to find in a string numbers (successively). It can be different count of digits on different lines.
Example:
1) text #11111111# text
2) text
3) text #555555555# text
I would like to get 2 rows:
1) 1111111
2) 555555555
Ok. Building on your previous thread, how about this?
data have;
input string $ 1-50;
datalines;
text #11111111# text
text
text #555555555# text
;
data want;
set have;
num=input(prxchange('s/.*#(\d+)#.*/\1/', -1, string), 8.);
if num;
run;
Result:
string num text #11111111# text 11111111 text #555555555# text 55555555
Do you simply want to extract numbers (0123456789) from a string or do they have to be enclosed in ##?
They have to be enclosed in ##
Ok. Building on your previous thread, how about this?
data have;
input string $ 1-50;
datalines;
text #11111111# text
text
text #555555555# text
;
data want;
set have;
num=input(prxchange('s/.*#(\d+)#.*/\1/', -1, string), 8.);
if num;
run;
Result:
string num text #11111111# text 11111111 text #555555555# text 55555555
Thanks a lot! It works!
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.