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

Capture.PNG

 

I want to separate the above column into different columns as given below

 

Nettype     Mesh    Dimension

Manta        333        1*0.17

Manta        333        1*0.17

1 ACCEPTED SOLUTION

Accepted Solutions
anushreebiotech
Obsidian | Level 7

Hi,

 

data have;
input path $50.;
datalines;
Manta/333/1*0.17
Manta/333/1*0.17
Manta/333/1*0.17
Manta/333/1*0.17
;
run;

data want;
set have;
Nettype= scan(path,1,'/');
Mesh= scan(path,2,'/');
Dimension= scan(path,3,'/');
run;

 

Regards,

Anushree

View solution in original post

4 REPLIES 4
anushreebiotech
Obsidian | Level 7

Hi,

 

data have;
input path $50.;
datalines;
Manta/333/1*0.17
Manta/333/1*0.17
Manta/333/1*0.17
Manta/333/1*0.17
;
run;

data want;
set have;
Nettype= scan(path,1,'/');
Mesh= scan(path,2,'/');
Dimension= scan(path,3,'/');
run;

 

Regards,

Anushree

andreas_lds
Jade | Level 19

Using the scan-function multiple-times, as suggested by @anushreebiotech, is the easiest way solve the issue. You should use the length-statement to ensure that the variable Nettype, Mesh and Dimension are long enough to store the parts extracted by scan.

mansour_ib_sas
Pyrite | Level 9

Hello,

I propose this solution:

data test;
var='Manta/333/1*0.17'; output;
var='Manta/ /1*0.17'; output;
var='Manta/333'; output;
var=' /Manta/333'; output;
; run;

data test1(drop=var i);
set test;
array vr(3) $ Nettype Mesh Dimension;
do i=1 to (countw(var,'/') );
vr(i)=scan(var,i,'/');
end;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2066 views
  • 5 likes
  • 5 in conversation