BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alexlor
Fluorite | Level 6
 
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;
 
The Tranwrd function is not working well (no replacement done).
Any ideas?
Thank you
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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));

 

View solution in original post

3 REPLIES 3
WarrenKuhfeld
Rhodochrosite | Level 12

try trimming folder2: trim(folder2)

Shmuel
Garnet | Level 18

In all your rows:  scan(folder1,1,'/')  ='F:'scan(folder2,1,'/');

 

Did you mean:

    where scan(folder1, -1,'/') = trim(folder2)

 

Tom
Super User Tom
Super User

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));

 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 3 replies
  • 2225 views
  • 1 like
  • 4 in conversation