I Have dataset like below..
data stansys;
infile datalines;
input string $22.;
datalines;
two numbers 1 2
five numbers 3 4 5 6 7
three numbers 8 9 10
;
run;
Through this dataset i want output dataset have variable name " Number" it have values like
1
2
3
4
5
6
7
8
9
10
like this only...
Please anyone help us to this programme
Like this?
data want(keep=w);
set stansys;
do i = 1 to countw(string);
w = scan(string, i);
if prxmatch('/\b\d+\b/', w) then output;
end;
run;
Result:
w 1 2 3 4 5 6 7 8 9 10
Like this?
data want(keep=w);
set stansys;
do i = 1 to countw(string);
w = scan(string, i);
if prxmatch('/\b\d+\b/', w) then output;
end;
run;
Result:
w 1 2 3 4 5 6 7 8 9 10
Hi @Mohan_Reddy
Here is another approach:
data want (keep=number);
set stansys;
do i=1 to countw(compress(string,"","Kd"));
number = scan(compress(string,"","Kd"),i);
output;
end;
run;
Thank You Very Much 🙂
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 save with the early bird rate—just $795!
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.