Hi,
data have;
input path $50.;
datalines;
/c:/user/new/path1/path2/path3/path4/cjx.sas
/c:/user/old/new/path1/path2/path3/path4/cjx.sas
/c:/user/new/path5/path2/path3/path4/cjx.sas
/c:/user/old/new/path5/path2/path3/path4/cjx.sas
;
run;
data want;
set have;
new_path= Tranwrd(path,'cjx.sas',"");
run;
Regards,
Anushree
Would this work:
data want;
FilePath = "/c:/user/new/path1/path2/path3/path4/cjx.sas";
Folder = substr(FilePath,1,length(FilePath)-length(scan(FilePath,-1,"/")));
run;
Or by using substr and findc:
data have_want;
length path directory $ 200;
input path;
directory = substr(path, 1, findc(path, '/', 'b'));
datalines;
/c:/user/new/path1/path2/path3/path4/cjx.sas
/c:/user/old/new/path1/path2/path3/path4/cjx.sas
/c:/user/new/path5/path2/path3/path4/cjx.sas
/c:/user/old/new/path5/path2/path3/path4/cjx.sas
;
run;
Hi,
data have;
input path $50.;
datalines;
/c:/user/new/path1/path2/path3/path4/cjx.sas
/c:/user/old/new/path1/path2/path3/path4/cjx.sas
/c:/user/new/path5/path2/path3/path4/cjx.sas
/c:/user/old/new/path5/path2/path3/path4/cjx.sas
;
run;
data want;
set have;
new_path= Tranwrd(path,'cjx.sas',"");
run;
Regards,
Anushree
data have_want;
length path directory $ 200;
input path;
directory = prxchange('s/[^\/]+$//',1,strip(path));
datalines;
/c:/user/new/path1/path2/path3/path4/cjx.sas
/c:/user/old/new/path1/path2/path3/path4/cjx.sas
/c:/user/new/path5/path2/path3/path4/cjx.sas
/c:/user/old/new/path5/path2/path3/path4/cjx.sas
;
run;
proc print;run;
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.