data have1;
input folder1 :$60. ;
cards;
F:/Drive1/Dataset/Table1
F:/Drive2/Dataset/Table2
F:/Drive3/Table
F:/Drive4
;
data have2;
input folder2 :$60. linux $60.;
cards;
F:/Drive1 /sas/data/drive1
F:/Drive2 /sas/data/drive2
F:/Drive1/Dataset /sas/data/dataset
F:/Drive2/Dataset /sas/data/dataset
F:/Drive3/ /sas/data/drive3
;
proc sql;
create table test as
select *
from have1, have2
where scan(folder1,1,'/') =scan(folder2,1,'/') ;
quit;
data a;
set test;
folder1 = tranwrd(folder1,folder2,linux);
run;
You need to trim the values passed to the TRANWRD() function since SAS stores variables as fixed length. You asked tranwrd to find values with many trailing spaces that are probably not actually in the values.
linux_folder1 = tranwrd(folder1,trim(folder2),trim(linux));
try trimming folder2: trim(folder2)
In all your rows: scan(folder1,1,'/') ='F:'
=
scan(folder2,1,'/');
Did you mean:
where scan(folder1, -1,'/') = trim(folder2)
You need to trim the values passed to the TRANWRD() function since SAS stores variables as fixed length. You asked tranwrd to find values with many trailing spaces that are probably not actually in the values.
linux_folder1 = tranwrd(folder1,trim(folder2),trim(linux));
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.