<?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 delete folders with files from SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433469#M107465</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is it possible to delete a complete folder with files in it with one singe statement ?&lt;/P&gt;&lt;P&gt;Or do you first need to remove the files and then the folders ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2018 10:58:59 GMT</pubDate>
    <dc:creator>Billybob73</dc:creator>
    <dc:date>2018-02-02T10:58:59Z</dc:date>
    <item>
      <title>delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433469#M107465</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is it possible to delete a complete folder with files in it with one singe statement ?&lt;/P&gt;&lt;P&gt;Or do you first need to remove the files and then the folders ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 10:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433469#M107465</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-02T10:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433475#M107470</link>
      <description>&lt;P&gt;Example 2:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245893.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245893.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do be careful, there is no way back though.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 11:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433475#M107470</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-02T11:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433477#M107471</link>
      <description>&lt;P&gt;The fdelete() function (which is the SAS tool for this) can only remove empty directories. Removing a non-empty directory will require XCMD and the proper command from the OS.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 11:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433477#M107471</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T11:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433480#M107472</link>
      <description>&lt;P&gt;Well, you could combine the first example, with a loop over dir and then a delete folder:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://amadeus.co.uk/sas-tips/listing-files-in-a-directory/" target="_blank"&gt;https://amadeus.co.uk/sas-tips/listing-files-in-a-directory/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So take the second box, replace the put line with an:&lt;/P&gt;
&lt;PRE&gt;rc=fdelete(physname);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Possibly need path as well - can't check at the moment.&amp;nbsp; Then at the end fdelete the folder.&lt;/P&gt;
&lt;P&gt;Not saying its ideal at any rate, but it is possible with just SAS functions.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 11:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433480#M107472</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-02T11:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433536#M107491</link>
      <description>&lt;P&gt;I used these. Rather than x commands. Thanks !&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 14:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433536#M107491</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-02T14:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433538#M107493</link>
      <description>&lt;P&gt;I combined both, but there's still a problem that remains. Folders which did not have files in them were not deleted.&lt;/P&gt;&lt;P&gt;General question : How can I delete empty folders with empty sub folders from SAS ? Is this possible ?&lt;/P&gt;&lt;P&gt;I tried x commands but they don't work despite path authorization and XCMD switched on.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 14:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433538#M107493</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-02T14:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433540#M107494</link>
      <description>&lt;P&gt;Just saying "it doesn't work" does not help at all.&amp;nbsp; Please show examples of what code you have tried.&lt;/P&gt;
&lt;P&gt;With the X command ones, likelihood is what you sent to the operating system was incorrect.&amp;nbsp; Again. code would show this.&amp;nbsp; Also note, that the commands for windows are different to linux/unix or other OS's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also out of interest, why do you want to do this, sounds more like a sys admin role than a SAS programming one.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 14:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433540#M107494</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-02T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433552#M107497</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You're right about that. I've been assigned as&amp;nbsp;sysadmin to get listings of files for our sas user community.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path = %nrstr(G:\TEST\R&amp;amp;D);&lt;/P&gt;&lt;P&gt;options noxwait ;&lt;BR /&gt;x "rmdir &amp;amp;path. /s /q";&lt;BR /&gt;options xwait;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 15:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433552#M107497</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-02T15:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433562#M107499</link>
      <description>&lt;P&gt;Then not sure why you are doing this in SAS?&amp;nbsp; &amp;nbsp;Anyways, something umped out at me&lt;/P&gt;
&lt;P&gt;%let path = %nrstr(G:\TEST\R&amp;amp;D);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yep, good old special characters in a system path.&amp;nbsp; Bad, bad, bad.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens when you run the code, can you run it with /q off and see what the system error is?&amp;nbsp; I suspect either the &amp;amp; is messing with macro resolution, or you lack some sort of permission/that folder doesn't exist.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 15:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433562#M107499</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-02T15:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433590#M107506</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The &amp;amp; is the reason I'm using a %nrstr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made some progress, but still not working unfo..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path=%nrstr(G:\TEST\R&amp;amp;D);&lt;BR /&gt;options noxsync noxwait noxmin;&lt;BR /&gt;&amp;nbsp; x rd /S /Q "&amp;amp;path";&lt;BR /&gt;options xwait;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something in the syntax is still not right........&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 16:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433590#M107506</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-02T16:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433608#M107516</link>
      <description>&lt;P&gt;Instead of the x statement, use the filename pipe method:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oscmd pipe "rd /S /Q '&amp;amp;path' 2&amp;gt;&amp;amp;1";

data _null_;
infile oscmd;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will show all output and messages in the SAS log.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 17:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433608#M107516</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-02T17:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433753#M107567</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Unfortunately this is not working&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 03:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433753#M107567</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-03T03:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433762#M107568</link>
      <description>&lt;P&gt;"not working" is very un-helpful.&lt;/P&gt;
&lt;P&gt;Please post the log.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 06:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433762#M107568</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-03T06:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433787#M107580</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found out that this is working :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options noxsync noxwait noxmin;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;x RD /S /Q &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;"%superq(folderdelete)"&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options xwait;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to your&amp;nbsp; hints I managed to do this&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 14:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433787#M107580</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-03T14:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: delete folders with files from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433791#M107581</link>
      <description>&lt;P&gt;By the way folderdelete is a macro variable that comes from a do loop. This is the loop code :&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%let max_id = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proc sql noprint; select max(id) into:max_id from deleterootfolders2; quit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%put &amp;amp;max_id.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%if %eval(&amp;amp;max_id.) ne&amp;nbsp; 0 %then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%do a=1 %to &amp;amp;max_id.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set deleterootfolders2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;call symputx('folderdelete', year_root);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where ID = &amp;amp;&amp;amp;a.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;options noxsync noxwait noxmin;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x RD /S /Q "%superq(folderdelete)";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;options xwait;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%end;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 14:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-folders-with-files-from-SAS/m-p/433791#M107581</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-03T14:25:47Z</dc:date>
    </item>
  </channel>
</rss>

