<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to delete all files in data step using fdelete function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707769#M217353</link>
    <description>Get it working for a single folder/file first. Then figure out how to loop it.</description>
    <pubDate>Tue, 22 Dec 2020 21:25:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-12-22T21:25:03Z</dc:date>
    <item>
      <title>how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551219#M153131</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME spec "%sysfunc(pathname(fptotb,f))/have.rtf"  ;

  DATA _NULL_ ;
  rc = FDELETE('spec') ;
  RUN ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi In my folder, there are &lt;FONT color="#FF0000"&gt;rft, lst, log, 7bdat&lt;/FONT&gt; are created with same name during a data step which i need to delete. for example, the temp file are&amp;nbsp; have.rtf, have.log, have.lst, have.7bdat.&amp;nbsp; With above pgm I am able to delete only rtf.&amp;nbsp; How to remove all in step.&amp;nbsp; Please suggest. Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 19:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551219#M153131</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2019-04-15T19:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551236#M153143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe if you do know files extensions in advance you can loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  fname="tempfile";
  length ext $ 20;
  do ext = "rtf", "lst", "log", "sas7bdat", "txt";

    rc=filename(fname, "%sysfunc(pathname(work))/have." !! strip(ext));
    if rc = 0 and fexist(fname) then
       rc=fdelete(fname);
    rc=filename(fname);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551236#M153143</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-04-15T20:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551255#M153152</link>
      <description>Do you have x commands enabled? In this case, if you do, a system command will accept wildcards which would help. &lt;BR /&gt;</description>
      <pubDate>Mon, 15 Apr 2019 21:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551255#M153152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-15T21:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551293#M153162</link>
      <description>&lt;P&gt;If you must use function fdelete(), then this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%* create files;
data _null_; 
 file "%sysfunc(pathname(work))/have.txt" ; put 'a';
 file "%sysfunc(pathname(work))/have.csv" ; put 'a';
run;

filename SPEC "%sysfunc(pathname(work))/have.*" ;

%* List files;
data FILENAMES;
  length _FILENAME $ 256; 
  infile SPEC filename=_FILENAME;
  input ; 
  FILENAME = _FILENAME;
run;
% Delete files;
data _null_; 
  set FILENAMES;  
  rc=filename ('TMPFREF',FILENAME); 
  rc=fdelete  ('TMPFREF') ;          
  rc=filename ('TMPFREF');           
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 02:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551293#M153162</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-16T02:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551294#M153163</link>
      <description>&lt;P&gt;If you needn't use function fdelete(), then this is easier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_; 
 file "%sysfunc(pathname(work))/have.txt" ; put 'a';
 file "%sysfunc(pathname(work))/have.csv" ; put 'a';
run;

filename DEL pipe "del ""%sysfunc(pathname(work))\have.*"" " ;

data FILENAMES;
  infile DEL ;
  input ; 
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any error messages generated during deletion go to the log window here, feel free to keep them in a table instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 03:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551294#M153163</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-16T03:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551366#M153175</link>
      <description>&lt;P&gt;You can get the all the file name by the following code ,and write CALL EXECUTE() to delete them one by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  DATA _NULL_ ;
  rc = filename('spec','c:\temp') ;
  did=dopen('spec');
  do i=1 to dnum(did);
   file_name=dread(did,i);
   put file_name= ;
  end;
  RUN ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2019 13:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/551366#M153175</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-16T13:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707703#M217326</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; , I stumbled upon this post looking for an alternate way to delete files from my directory on a server than using the x command.&amp;nbsp; Normally, if I use an x command with a wildcard to delete *.xlsx files it works, however, we are running into issues where it won't work for some reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading your reply, I got this syntax to work to generate a list of my files in that directory.&amp;nbsp; Can you advise on how I would use the CALL EXECUTE() to delete the files now?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_ ;
  rc = filename('spec','c:\temp') ;
  did=dopen('spec');
  do i=1 to dnum(did);
   file_name=dread(did,i);
   put file_name= ;
  end;
  RUN ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 16:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707703#M217326</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T16:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707709#M217329</link>
      <description>Wrap that in a macro function and call it via CALL EXECUTE the same way I wrote that last program for you.</description>
      <pubDate>Tue, 22 Dec 2020 16:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707709#M217329</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-22T16:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707719#M217333</link>
      <description>What I don't understand is how the files actually get deleted.  Where &amp;amp; how in that code do I tell it to delete each of those files?&lt;BR /&gt;&lt;BR /&gt;That last program to help me cat the variables in the file name was great.  Thank you for that.</description>
      <pubDate>Tue, 22 Dec 2020 17:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707719#M217333</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T17:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707722#M217334</link>
      <description>Add the FDELETE function into the loop using the fileref definition or path. file_name gave you the filename and you have the path so you can create the full path if needed.&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Dec 2020 17:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707722#M217334</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-22T17:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707734#M217338</link>
      <description>&lt;P&gt;I have tried a few ways and can't get it to work correctly.&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;I could only get the directory name working if I created a variable.&amp;nbsp; I think that's probably an extra step but couldn't get it to work otherwise.&amp;nbsp; If I run this code with the put fname uncommented, I see the complete path and file name in the SAS log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let directoryname = "/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/";

DATA _NULL_ ;
  rc = filename('spec',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/") ;
  did=dopen('spec');
  do i=1 to dnum(did);
   file_name=dread(did,i);
   /*put file_name= ;*/
   fname=cats(&amp;amp;directoryname,file_name);
   put fname;
   /*rc=fdelete(fname);*/
  end;
RUN ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_0-1608662078535.png" style="width: 677px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52964iA0F5C86BA55AC259/image-dimensions/677x229?v=v2" width="677" height="229" role="button" title="elwayfan446_0-1608662078535.png" alt="elwayfan446_0-1608662078535.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking, "OK, these are the files I need deleted, let's go".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I run the code with rc=fdelete(fname);&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_ ;
  rc = filename('spec',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/") ;
  did=dopen('spec');
  do i=1 to dnum(did);
   file_name=dread(did,i);
   /*put file_name= ;*/
   fname=cats(&amp;amp;directoryname,file_name);
   /*put fname;*/
   rc=fdelete(fname);
  end;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I now get the following notes in the log and the files have not been deleted:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_1-1608662266407.png" style="width: 608px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52965iA69AD823127099CB/image-dimensions/608x225?v=v2" width="608" height="225" role="button" title="elwayfan446_1-1608662266407.png" alt="elwayfan446_1-1608662266407.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been referencing this documentation from SAS as well and just can't seem to put it all together.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=8.1&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0h945u5r0cv6yn1u6qs35hiqt9t.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=8.1&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0h945u5r0cv6yn1u6qs35hiqt9t.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 18:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707734#M217338</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T18:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707752#M217345</link>
      <description>It seems to want the fileref not the filename. You can create a fileref using the FILENAME function, similar to the first line of code.</description>
      <pubDate>Tue, 22 Dec 2020 20:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707752#M217345</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-22T20:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707768#M217352</link>
      <description>&lt;P&gt;I tried this according to the SAS documentation I found.&amp;nbsp; I just can't put it all together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let directoryname = "/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/";

DATA _NULL_ ;
  rc = filename('spec',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/") ;
  did=dopen('spec');
  do i=1 to dnum(did);
    file_name=dread(did,i);
   /*put file_name= ;*/
   fname=cats(&amp;amp;directoryname,file_name);
   /*put fname;*/
   /*rc=fdelete(fname);*/
  end;
RUN ;


%macro test;                                                                                                                            
 %let filrf= "/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/";                                                                                                                     
 %let rc=%sysfunc(filename(filrf, file_name=));                                                                                  
 %if &amp;amp;rc ne 0 %then %put %sysfunc(sysmsg());                                                                                            
 %let rc=%sysfunc(filename(filrf));                                                                                                     
%mend test;   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Dec 2020 21:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707768#M217352</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T21:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707769#M217353</link>
      <description>Get it working for a single folder/file first. Then figure out how to loop it.</description>
      <pubDate>Tue, 22 Dec 2020 21:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707769#M217353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-22T21:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707778#M217357</link>
      <description>&lt;P&gt;Sorry for all of the back and forth.&amp;nbsp; I promise I am not someone who needs their homework answered, I have just been racking my brain on this one and the other regarding the excel export files for a week.&amp;nbsp; I try not to post for help unless it is a last resort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying it with a single file in that directory.&amp;nbsp; When I try what looks right (and probably isn't at this point), I can %put the filrf but when I %put rc it gives me what looks like a number in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_ ;
  %let filrf="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/";	
  %let rc=%sysfunc(filename(filrf, 202011_360_Mortgage__LLC.xlsx));
  %put &amp;amp;filrf;
  %put &amp;amp;rc;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_1-1608675621515.png" style="width: 822px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52968i61237A9F95A1F1E1/image-dimensions/822x300?v=v2" width="822" height="300" role="button" title="elwayfan446_1-1608675621515.png" alt="elwayfan446_1-1608675621515.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 22:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707778#M217357</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T22:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707785#M217362</link>
      <description>&lt;P&gt;I have it working for one file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* THIS WORKS ON ONE FILE */
DATA _NULL_ ;
  rc = filename('fname',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/202011_All_Western_Mortgage__Inc..xlsx");
  rc = fdelete('fname');	
RUN ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have tried to modify it to loop through all of the files in the directory with no luck.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_ ;
  rc = filename('fpath',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/");
  	did=dopen('fpath');
  	do i=1 to dnum(did);
	  file_name=dread(did,i);
	  /*put file_name;*/
  		rc = filename('fname',catx('fpath',file_name));
		put fname;
  		/*rc = fdelete('fname');*/	
	end;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This block of code gives me these results when I put to the log:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_0-1608679772872.png" style="width: 692px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52970i720B5BD8AC7840F3/image-dimensions/692x268?v=v2" width="692" height="268" role="button" title="elwayfan446_0-1608679772872.png" alt="elwayfan446_0-1608679772872.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I appreciate everyone wanting me to figure this one out on my own, however, I have spent several days on this and need to figure this out to complete a project for my team.&amp;nbsp; If you could just show me and example on how I need to change my code I would greatly appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 23:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707785#M217362</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T23:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707794#M217366</link>
      <description>&lt;P&gt;File_name is the name of your file not FNAME - there is no FNAME variable. Try this, if RC = 0&amp;nbsp; - the FILENAME function is successful - then the DELETE is done.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_ ;
  rc = filename('fpath',"/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/");
  	did=dopen('fpath');
  	do i=1 to dnum(did);
	  file_name=dread(did,i);
	  /*put file_name;*/
  		rc = filename('fname',catx('fpath',file_name));
		put file_name = rc = ;
  		if rc = 0 then rc = fdelete('fname');	
	end;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2020 01:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707794#M217366</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-12-23T01:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707795#M217367</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc = filename('fname',catx('fpath',file_name));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is wrong. FPATH is not the path. 'FPATH' even less.&lt;/P&gt;
&lt;P&gt;Also, function catx is used wrongly.&lt;/P&gt;
&lt;P&gt;Maybe this?&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;RC = filename('FNAME',cats(pathname('FPATH'),FILE_NAME));	&lt;/LI-CODE&gt;
&lt;P&gt;Use might need a slash separator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 01:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707795#M217367</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-12-23T01:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707890#M217426</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;This code ran successfully but the files were not deleted.&amp;nbsp; Here is the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_0-1608732318743.png" style="width: 776px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52984iB1B20AC06C7DFD64/image-dimensions/776x282?v=v2" width="776" height="282" role="button" title="elwayfan446_0-1608732318743.png" alt="elwayfan446_0-1608732318743.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Files still out there:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_1-1608732372857.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52985iFF648AB5E4D00EC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="elwayfan446_1-1608732372857.png" alt="elwayfan446_1-1608732372857.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am starting to wonder if there is something wrong with the actual filepath or file names that are preventing these types of mass delete since x commands are only working on hard coded files too.&amp;nbsp; So frustrating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 14:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707890#M217426</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-23T14:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete all files in data step using fdelete function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707891#M217427</link>
      <description>&lt;P&gt;Thansk &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;.&amp;nbsp; I tried this adjustment as well.&amp;nbsp; Same results as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;'s script.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 14:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-all-files-in-data-step-using-fdelete-function/m-p/707891#M217427</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-23T14:11:06Z</dc:date>
    </item>
  </channel>
</rss>

