<?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: Auto deleting old tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462683#M117822</link>
    <description>&lt;P&gt;Thank you for your answer, but the thing is that these tables are populated by a batch code. I dont have the chance to edit these codes so I have to find a way to delete today()-10 date tables.&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2018 13:29:53 GMT</pubDate>
    <dc:creator>dincooo</dc:creator>
    <dc:date>2018-05-16T13:29:53Z</dc:date>
    <item>
      <title>Auto deleting old tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462654#M117812</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have daily populated SAS tables under a library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These tables are in the format like that: (date is in the end)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table_x20180516&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;table_x20180515&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;table_x20180514&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;table_xy20180516&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;table_xy20180515&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to write a script that runs at the server and deletes today()-10 dated tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can i write that kind of script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Onur&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 12:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462654#M117812</guid>
      <dc:creator>dincooo</dc:creator>
      <dc:date>2018-05-16T12:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Auto deleting old tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462665#M117817</link>
      <description>&lt;P&gt;I would ask your IT to setup a daily job to do this, rather than writing SAS code to do it.&lt;/P&gt;
&lt;P&gt;But then I would have all that data in one dataset, with a variable date in the data, that way I only have one dataset containing my data, and then I really have a very simple life of filter out the data I want to remove by:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  where file_date &amp;gt;= today()-10;
run;&lt;/PRE&gt;
&lt;P&gt;One dataset, with the data in variables is so much easier to work with than splitting data up into multiple files, and having data items in filenames.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 13:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462665#M117817</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-16T13:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Auto deleting old tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462683#M117822</link>
      <description>&lt;P&gt;Thank you for your answer, but the thing is that these tables are populated by a batch code. I dont have the chance to edit these codes so I have to find a way to delete today()-10 date tables.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 13:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462683#M117822</guid>
      <dc:creator>dincooo</dc:creator>
      <dc:date>2018-05-16T13:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Auto deleting old tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462763#M117855</link>
      <description>&lt;P&gt;If it has to be done in SAS code then that's possible. This would be a way to do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lib=MYLIB;
data tables;
	set sashelp.vtable(where=(libname="&amp;amp;lib"));
	if index(memname, '2018');
	memdate = substr(memname, length(memname)-8+1); /* Take last 8 positions as the date */
	if today() - input(memdate, yymmdd8.) &amp;gt; 10 then do; /* Older than 10 days */
		call execute ("proc delete data=&amp;amp;lib.." || trim(memname) || '; run;');		
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would probably want to refine this (testing only the proper members are taken into account) but is is meant as a start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this help,&lt;/P&gt;
&lt;P&gt;-- Jan&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 16:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Auto-deleting-old-tables/m-p/462763#M117855</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2018-05-16T16:08:27Z</dc:date>
    </item>
  </channel>
</rss>

