Hello all,
I'm reading file names into a dataset from a directory:
filename File_Dir pipe "dir &Dir";
data File_List;
infile File_Dir truncover;
input folderlist $char1000.;
length
folder file $75.
extension $6.
date 8;
retain folder;
if index(folderlist,'Directory') > 0 then folder = substr(folderlist,14,180);
if scan(folderlist,2,'.') ne ' ' then do;
file = strip(scan(substr(folderlist,40,160),1,'.'));
extension = upcase(scan(strip(folderlist),-1,'.'));
date = mdy(input(substr(folderlist,1,2),8.),input(substr(folderlist,4,2),8.),input(substr(folderlist,7,4),8.));
size = input(strip(substr(folderlist,30,10)),comma32.);
end;
if date ne .;
if findc(extension,'~%%$') = 0;
keep Folder File Extension Date ;
format Date mmddyy10.;
run;
My problem is that no matter how I try to strip away blank spaces from the File name they stay at a length of 75. This is creating file name issues later on when I try to export updated versions of the files using the same name.
I'm getting something like "Example File Name .xlsx"
I've tried strip, compress, trim, etc and cant seem to figure out how to get rid of that extra space. I can manully change the length of the File variable but that's defeating the purpose. Is there a way to dynamically change the length of the File variable to the max length of File?
Appreciate the thoughts. thanks.
... View more