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!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.