Hi, I am having problems trying to edit some code to delete specific excel files from a folder. I have a list of filenames and extensions in a table already in SAS, so I just need the code to find those filenames and delete them. I found the below code online and it does delete all the .xlsx .xls files in a folder. However I don't want to delete all files, only the ones within my dataset work.FileN. Code: %let path=D:\temp;
filename filrf "&path.";
data test;
/*Set work.FileN; This holds all the filenames and extensions e.g P1.xlsx, P2.xlsx etc.. in column called filename */
did = dopen('filrf');
memcount = dnum(did);
do while (memcount>0);
fname = dread(did,memcount);
if
scan(lowcase(fname),2,'.') in ('xls','xlsx')
then do;
rcref = filename('fref',catx('\',"&path.",fname));
rcdel = fdelete('fref');
end;
memcount+-1;
end;
stop;
run;
... View more