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
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
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
Nice solution. Simple and works.
Just take care of Maxim 47 and set explicit lengths for the results, either to avoid waste of space or truncation.
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.
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;
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.