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