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

 

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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

 

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

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

 

Mohan_Reddy
Obsidian | Level 7
Any Another type programme we have for this same question ???
ed_sas_member
Meteorite | Level 14

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;
Mohan_Reddy
Obsidian | Level 7

Thank You Very Much 🙂

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 624 views
  • 1 like
  • 3 in conversation