<?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: Issue While trying to delete png files using systask command in a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/883551#M349097</link>
    <description>&lt;P&gt;Thank you for helping to solve the issue. Your suggested solution worked for me!!&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2023 12:39:10 GMT</pubDate>
    <dc:creator>sathyarajamohan</dc:creator>
    <dc:date>2023-07-05T12:39:10Z</dc:date>
    <item>
      <title>Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882147#M348534</link>
      <description>&lt;P&gt;I was trying to delete png files (500000+) using systask command in a do loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My loop stops in the 6482 loop count. Is there any reason or limit set in the loop while deleting the files this way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO LOOP;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;create table DSNAME as SELECT distinct memname FROM DICTIONARY.COLUMNS&lt;BR /&gt;WHERE UPCASE(LIBNAME)="WORK" AND&lt;BR /&gt;UPCASE(MEMNAME)LIKE "FINAL_SPLIT%";&lt;BR /&gt;select count(*) into :datasetcnt from DSNAME;&lt;BR /&gt;QUIT;&lt;BR /&gt;%put &amp;amp;datasetcnt.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do p=1 %to &amp;amp;datasetcnt.;&lt;BR /&gt;DATA _null_;&lt;BR /&gt;SET FINAL_SPLIT_&amp;amp;p.;&lt;BR /&gt;CALL SYMPUT( "FN" || LEFT(TRIM(_N_)) , trim(file_name) );&lt;BR /&gt;CALL SYMPUT( "totcnt",_N_ );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/*%put &amp;amp;fn1.;*/&lt;/P&gt;&lt;P&gt;libname mylib &amp;amp;clrfold.;&lt;/P&gt;&lt;P&gt;%do i = 1 %to &amp;amp;totcnt.;&lt;/P&gt;&lt;P&gt;%let path=%sysfunc(pathname(mylib));&lt;BR /&gt;systask command&lt;BR /&gt;"del ""&amp;amp;path.\&amp;amp;&amp;amp;fn&amp;amp;i.."""&lt;BR /&gt;wait taskname="deleting";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%MEND LOOP;&lt;BR /&gt;%LOOP;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 14:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882147#M348534</guid>
      <dc:creator>sathyarajamohan</dc:creator>
      <dc:date>2023-06-23T14:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882152#M348535</link>
      <description>&lt;P&gt;Why are you using %SYSTASK?&lt;/P&gt;
&lt;P&gt;Why are you calling is separately for every file?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I cannot figure out what the beginning of your program has to do with the question about deleting PNG files.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have dataset with a list of files to delete.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  infile cards truncover ;
  input filename $200.;
cards;
file1.png
file2.png
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use that to generate one DEL command for each file named. So something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   set files;
   length cmd $300 msg $300 ;
   cmd = 'DEL '||quote(trim(filename)) ;
   infile dummy pipe filevar=cmd end=eof;
   do while(not eof);
      input ;
      msg=catx(' ',msg,_infile_);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 15:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882152#M348535</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-23T15:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882155#M348536</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend a non-macro, non-systask approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib &amp;amp;clrfold.;
%let path=%sysfunc(pathname(mylib));

data list_files;
*combines all files that start with the prefix final_split into one dataset;
set work.final_split: ;

*creates file path;
file_path = catx("\", "&amp;amp;path.", file_name);

fname = "tempfile";

*checks if file exists and deletes file;
    rc=filename(fname, file_path);
    if rc = 0 and fexist(fname) then
       rc_delete=fdelete(fname);
    rc=filename(fname);

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 15:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882155#M348536</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-23T15:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882259#M348580</link>
      <description>&lt;P&gt;You can use OS command to get all these png's path. and issue X command to delete them all.&lt;/P&gt;
&lt;P&gt;If you are using Windows OS . and c:\temp\ is ROOT directory for all the PNG files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x pipe 'dir c:\temp\*.png /s /b';
filename z 'c:\temp\del.bat';
data _null_;
infile x length=len;
input x $varying200. len;
com='del '||x;

file z;
put com;
run;

options  noxwait;
x 'c:\temp\del.bat';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Jun 2023 10:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/882259#M348580</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-24T10:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/883551#M349097</link>
      <description>&lt;P&gt;Thank you for helping to solve the issue. Your suggested solution worked for me!!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 12:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/883551#M349097</guid>
      <dc:creator>sathyarajamohan</dc:creator>
      <dc:date>2023-07-05T12:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue While trying to delete png files using systask command in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/883552#M349098</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to archive/zip some selected date files and once the archival is done i am trying to delete those related files. Thank you for trying to help me!!! I will use your solution when its best suited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 12:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-While-trying-to-delete-png-files-using-systask-command-in/m-p/883552#M349098</guid>
      <dc:creator>sathyarajamohan</dc:creator>
      <dc:date>2023-07-05T12:41:27Z</dc:date>
    </item>
  </channel>
</rss>

