<?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: delete files with sas Data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393069#M94642</link>
    <description>&lt;P&gt;I think this might not be 100% useful for my case, because in the list that I have I also have directories with subdirectories and files in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to shell out because I wanted to use the -rf option on rm command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2017 23:49:49 GMT</pubDate>
    <dc:creator>iscgonzalez</dc:creator>
    <dc:date>2017-09-04T23:49:49Z</dc:date>
    <item>
      <title>delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393064#M94639</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to delete multiple files that are contained in a dataset, the dataset&amp;nbsp; contains data like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Path&lt;/P&gt;
&lt;P&gt;-----------------&lt;/P&gt;
&lt;P&gt;/test/file1.txt&lt;/P&gt;
&lt;P&gt;/test/file2.txt&lt;/P&gt;
&lt;P&gt;/test/file3.txt&lt;/P&gt;
&lt;P&gt;/test/file4.txt&lt;/P&gt;
&lt;P&gt;/test/file5.txt&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I want to do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set path_table;&lt;/P&gt;
&lt;P&gt;call symput('file',path);&lt;/P&gt;
&lt;P&gt;x "rm -rf &amp;amp;file";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but before I submit the command I wanted to test what I'm sending to the x window with something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set work.files;&lt;BR /&gt;call symput('file',path);&lt;BR /&gt;%put &amp;amp;file;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm just getting one line in the log. what can I be possibly be doing wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 23:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393064#M94639</guid>
      <dc:creator>iscgonzalez</dc:creator>
      <dc:date>2017-09-04T23:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393065#M94640</link>
      <description>&lt;P&gt;Your macro variable won't resolve until the end of the datastep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would just create a variable and run it within the datastep (e.g (untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; set work.archivos2;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; length commd $80;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; let commd=catx(' ','x "rm -rf',path,'"');&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; call execute(commd);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Art, CEO, AnalystFinder.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 23:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393065#M94640</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-04T23:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393067#M94641</link>
      <description>&lt;P&gt;No need to shell out to the operating system e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length path $50;
	infile datalines;
	input path;
	datalines;
/folders/myshortcuts/Dropbox/Test/file1.txt
/folders/myshortcuts/Dropbox/Test/file2.txt
/folders/myshortcuts/Dropbox/Test/file3.txt
;
run;

data _null_;
	set have;	
	fname="temp";
    rc=filename(fname,path);
    if rc = 0 and fexist(fname) then
       rc=fdelete(fname);
    rc=filename(fname);
   
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Sep 2017 23:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393067#M94641</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-04T23:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393069#M94642</link>
      <description>&lt;P&gt;I think this might not be 100% useful for my case, because in the list that I have I also have directories with subdirectories and files in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to shell out because I wanted to use the -rf option on rm command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 23:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393069#M94642</guid>
      <dc:creator>iscgonzalez</dc:creator>
      <dc:date>2017-09-04T23:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393077#M94643</link>
      <description>&lt;P&gt;FDELETE is a better option, because X command can be disabled on many systems and the commands will vary based on OS, whereas FDELETE will not change.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 01:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393077#M94643</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-05T01:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: delete files with sas Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393087#M94648</link>
      <description>&lt;P&gt;You would do better to use CALL SYMPUTX instead of CALL SYMPUT. &amp;nbsp;That way, the softtware automatically removes leading and trailing blanks from the macro variable it creates. &amp;nbsp;Even if you get the %PUT statement to execute the way you intend, it won't necessarily show leading and trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%PUT statements are never part of a DATA step. &amp;nbsp;You could easily use a PUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put path;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use %PUT you would need to jump through quite a few hoops: &amp;nbsp;find out the number of paths in your data set, write a macro loop that goes through a DATA step reading just one observation, then executes %put. &amp;nbsp;If that's worth it, we can look at some details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;One final thought about a trick that may work: &amp;nbsp;try changing the %PUT statement to read:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute('%put &amp;amp;file;');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALL EXECUTE will execute macro statements immediately, so may be able to track the current value of &amp;amp;FILE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Update:&amp;nbsp; Confirmed that the last idea above does actually work.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 12:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-files-with-sas-Data-step/m-p/393087#M94648</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-05T12:45:06Z</dc:date>
    </item>
  </channel>
</rss>

