<?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: deleting observations older than 6 years  from all the tables from  different libs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448138#M112700</link>
    <description>&lt;P&gt;You can retrieve a list of datasets from dictionary.tables (in proc sql). With a suitable where condition, you will get all those you want to delete.&lt;/P&gt;
&lt;P&gt;This can then be used to dynamically delete datasets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set datasets_to_delete end=eof;
if _n_ = 1 then call execute('proc delete data=');
call execute(' ' !! trim(libname) !! '.' !! trim(memname));
if eof then call execute('; run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Mar 2018 13:06:32 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-03-23T13:06:32Z</dc:date>
    <item>
      <title>deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448094#M112677</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;as part of deletion routine. I want to&amp;nbsp;delete the observations( older than 6 years)&amp;nbsp; from all the tables from&amp;nbsp; different libs. below code works but I am not sure how to use in all programmes. is there any easy method&amp;nbsp;if we &amp;nbsp;tweet a macro. it will automatically delete the observations (older than 6 years).&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(application);
if &amp;amp;application ge intnx('year' ,today(),-6,'s');

%mend test;

data test;
set test1;
%test(date);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for the help.&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 10:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448094#M112677</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-23T10:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448112#M112688</link>
      <description>&lt;P&gt;If you change the macro so that it contains all the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro reduce(libname,memname,testvar);
data &amp;amp;libname..&amp;amp;memname._red;
set &amp;amp;libname..&amp;amp;memname;
if &amp;amp;testvar ge intnx('year' ,today(),-6,'s');
run;
%mend test;

/* typical call: */
%reduce(work,test,date);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you can now call it automated from a dataset that contains the necessary values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set control;
call execute('%reduce(' !! trim(libname) !! ',' !! trim(memname) !! ',' !! trim(varname) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 12:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448112#M112688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-23T12:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448131#M112695</link>
      <description>Hi ,&lt;BR /&gt;Thank you .it is working . This is for a history data for each table.&lt;BR /&gt;what about the history tables. need to delete the history tables also from the libraries.&lt;BR /&gt;&lt;BR /&gt;I have tables like April2009_ext&lt;BR /&gt;April2010,etc (each table has date stamp on them) from different libs.&lt;BR /&gt;Thanks,&lt;BR /&gt;SS&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Mar 2018 12:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448131#M112695</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-23T12:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448138#M112700</link>
      <description>&lt;P&gt;You can retrieve a list of datasets from dictionary.tables (in proc sql). With a suitable where condition, you will get all those you want to delete.&lt;/P&gt;
&lt;P&gt;This can then be used to dynamically delete datasets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set datasets_to_delete end=eof;
if _n_ = 1 then call execute('proc delete data=');
call execute(' ' !! trim(libname) !! '.' !! trim(memname));
if eof then call execute('; run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 13:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448138#M112700</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-23T13:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448155#M112704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this is not working with your logic above or I am I wrong to apply what you said in this post&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc sql;
	   create table a as 
          select
             memname
/*          into*/
/*             :dsns separated by " "*/
          from
             sashelp.vtable
          where
                libname="work"
            and  typemem="DATA"
            and  intck("month",datepart(crdate),today()) &amp;gt;1
       ;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 13:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448155#M112704</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-23T13:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448158#M112707</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;you can now call it automated from a dataset that contains the necessary values.
data _null_;
set control;
call execute('%reduce(' !! trim(libname) !! ',' !! trim(memname) !! ',' !! trim(varname) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and also above logic is not working for me. What will control table have? one example please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 13:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448158#M112707</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-23T13:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448160#M112709</link>
      <description>&lt;P&gt;I guess you will always have a hard time finding datasets in your WORK that are older than a month, unless you have a single SAS session up permanently. Also keep in mind that libnames in dictionary tables are always uppercase.&lt;/P&gt;
&lt;P&gt;Try this for starters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table a as 
select
  memname
from dictionary.tables
where
  libname="SASUSER"
  and typemem="DATA"
  and intck("month",datepart(crdate),today()) &amp;gt; 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;sashelp.vtable is a view on dictionary.tables, and is usually slower to use than dictionary.tables, as there SQL can optimize the where condition.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448160#M112709</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-23T14:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448163#M112711</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93352"&gt;@sathya66&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;you can now call it automated from a dataset that contains the necessary values.
data _null_;
set control;
call execute('%reduce(' !! trim(libname) !! ',' !! trim(memname) !! ',' !! trim(varname) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and also above logic is not working for me. What will control table have? one example please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's a dataset that contains libname, memname and variable name for all datasets/variables that you want to have corrected.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448163#M112711</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-23T14:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations older than 6 years  from all the tables from  different libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448165#M112712</link>
      <description>Thank you. Now I am clear.</description>
      <pubDate>Fri, 23 Mar 2018 14:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-older-than-6-years-from-all-the-tables/m-p/448165#M112712</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-23T14:18:32Z</dc:date>
    </item>
  </channel>
</rss>

