<?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: macro in libname in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351554#M81826</link>
    <description>&lt;P&gt;If possible using a concatenated libref as suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; will simplify greatly and reduce the need for the recursive macro. Duplicate file names in subfolders could be problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you cannot change the naming convention of the files, unfortunately an all too common reality, the following macro will delete a file from a provided location (fileref).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Fdel(fileref=, filename=);
%local dd yy mon filedate rc tref;
%let tref=temref;
%* assume file name is in the form of:
%* xxxdd_YYYYmon.sas7bdat;
%let dd = %substr(&amp;amp;filename,4,2);
%let yy = %substr(&amp;amp;filename,7,4);
%let mon = %substr(&amp;amp;filename,11,3);
%let filedate = %eval(%sysfunc(inputn(&amp;amp;mon&amp;amp;yy,monyy7.)) + &amp;amp;dd - 1);
%if %sysfunc(intnx(month,&amp;amp;filedate,24,s)) lt %sysfunc(date()) %then %do;
   %let rc = %sysfunc(filename(tref,%sysfunc(pathname(&amp;amp;fileref))\&amp;amp;filename));
   %let rc = %sysfunc(fdelete(temref));
   %let rc = %sysfunc(filename(temref));
%end;
%mend fdel;

filename myloc 'c:\temp';
%fdel(fileref=myloc, filename= ab002_2015apr.sas7bdat)
%fdel(fileref=myloc, filename= gh005_2015mar.sas7bdat)
%fdel(fileref=myloc, filename= gh015_2016nov.sas7bdat)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have made some assumptions about your file naming conventions - adjust as needed.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2017 06:02:18 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2017-04-20T06:02:18Z</dc:date>
    <item>
      <title>macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351514#M81809</link>
      <description>&lt;P&gt;&lt;SPAN class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to develop a&amp;nbsp; global macro that checks nearly 12&amp;nbsp;folders under the DEVELOPMENT folder and if it finds any dataset name older than 24 months (note: not create date, but the name of the dataset eg: ab002_2015apr, gh005_2015mar) it should delete&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;folder:&lt;/P&gt;&lt;P&gt;DEVELOPMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 abc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 vbg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 jil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;1 abc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 vbg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 jil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; crc&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;1 abc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 vbg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 jil&lt;/P&gt;&lt;P&gt;under Development i have 13 folders and under each folder there are 4 sub folders , and i need to serch the DATASET folder which has SAS datasets stored and delete datasets&amp;nbsp; nmes, which are older than 24 months&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code should delete all the datasets whose name is 24 months older&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Apr 2017 02:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351514#M81809</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-20T02:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351545#M81822</link>
      <description>&lt;P&gt;You need a macro that will recursively crawl through your directory (and subdirectories).&amp;nbsp; You can find an example of such a macro in the 9.4 macro language reference manual &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm&lt;/A&gt;.&amp;nbsp; A somewhat more sophisticated version of this macro can be found in my SAS Global Forum paper &lt;A href="http://support.sas.com/resources/papers/proceedings17/0835-2017.pdf" target="_self"&gt;http://support.sas.com/resources/papers/proceedings17/0835-2017.pdf&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 05:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351545#M81822</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2017-04-20T05:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351547#M81824</link>
      <description>&lt;P&gt;It might be easier to concatenate all the paths into one libname and just scan this one library over and over until all matching&amp;nbsp;tables are deleted.&lt;/P&gt;
&lt;P&gt;Also, you really should consider using 201501 instead of 2015jan. This makes this kind of job easier, and automatically sorts the table&amp;nbsp;list&amp;nbsp;in a meaningful order in the SAS (or OS) explorer.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 05:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351547#M81824</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-04-20T05:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351554#M81826</link>
      <description>&lt;P&gt;If possible using a concatenated libref as suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; will simplify greatly and reduce the need for the recursive macro. Duplicate file names in subfolders could be problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you cannot change the naming convention of the files, unfortunately an all too common reality, the following macro will delete a file from a provided location (fileref).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Fdel(fileref=, filename=);
%local dd yy mon filedate rc tref;
%let tref=temref;
%* assume file name is in the form of:
%* xxxdd_YYYYmon.sas7bdat;
%let dd = %substr(&amp;amp;filename,4,2);
%let yy = %substr(&amp;amp;filename,7,4);
%let mon = %substr(&amp;amp;filename,11,3);
%let filedate = %eval(%sysfunc(inputn(&amp;amp;mon&amp;amp;yy,monyy7.)) + &amp;amp;dd - 1);
%if %sysfunc(intnx(month,&amp;amp;filedate,24,s)) lt %sysfunc(date()) %then %do;
   %let rc = %sysfunc(filename(tref,%sysfunc(pathname(&amp;amp;fileref))\&amp;amp;filename));
   %let rc = %sysfunc(fdelete(temref));
   %let rc = %sysfunc(filename(temref));
%end;
%mend fdel;

filename myloc 'c:\temp';
%fdel(fileref=myloc, filename= ab002_2015apr.sas7bdat)
%fdel(fileref=myloc, filename= gh005_2015mar.sas7bdat)
%fdel(fileref=myloc, filename= gh015_2016nov.sas7bdat)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have made some assumptions about your file naming conventions - adjust as needed.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 06:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351554#M81826</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2017-04-20T06:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351557#M81827</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately i annot concatenate all paths in to one file name, as all the folders are different channels of business.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i can cahange the naming convention of the datasets, to ab002_201501 instead of ab002_2015jan&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 06:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351557#M81827</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-20T06:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351559#M81828</link>
      <description>Also my folder has the following files&lt;BR /&gt;ab002_201501&lt;BR /&gt;ab003_201501&lt;BR /&gt;ab007_201501&lt;BR /&gt;3 different files with similar naming convention, so I need a code to delete the files older than 24 months from today irrespective of the prefix(ab002_or ab003_ or ab007)&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Apr 2017 06:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351559#M81828</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-20T06:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351670#M81876</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32726"&gt;@SAS_INFO&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately i annot concatenate all paths in to one file name, as all the folders are different channels of business.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i can cahange the naming convention of the datasets, to ab002_201501 instead of ab002_2015jan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This us not a request to combine the directory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A SAS library can point to multiple folders, so if the subfolder names are consistent a single libname could reference all folders at once. Then you can revert to the original solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 13:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351670#M81876</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351950#M82004</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

libname A 'path1';
libname B 'path2';
libname C 'path3';
libname D 'path4';
libname CONCAT (A B C D);

%let table=;

data _null_;
  OLDEST_ALLOWED='201503';

  do until(symget('table')=' ');
   RC=dosubl( 'data _null_;'
            ||'call symputx("table"," ");'
            ||'set SASHELP.VSTABLE; '
            ||'where LIBNAME="CONCAT" and '
            ||'trim(MEMNAME) like "%20____" and '
            ||'substr(MEMNAME, length(MEMNAME)-5,6) &amp;lt;' ||quote(OLDEST_ALLOWED)
            ||';call symputx("table",MEMNAME); stop; run;');
   if lengthn(symget('table')) then
      CR=dosubl( 'proc delete data=CONCAT.'||symget('table')||';run;');
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 23:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/351950#M82004</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-04-20T23:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353524#M82524</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Instead of passing the oldest allowed parameter , i have made a slight modification , as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please correctme if am wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oldest_allowed=catt(year(today())-2,"_",month(today())-2);&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 00:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353524#M82524</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-26T00:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353527#M82525</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32726"&gt;@SAS_INFO&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;Instead of passing the oldest allowed parameter , i have made a slight modification , as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please correctme if am wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oldest_allowed=catt(year(today())-2,"_",month(today())-2);&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've made a mistake. What if&amp;nbsp;it's January?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 00:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353527#M82525</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-26T00:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353531#M82527</link>
      <description>Ideally the code needs to delete the file which is 24 months older and to be in safer side we are deleting any dataset older than 25 months.&lt;BR /&gt;&lt;BR /&gt;so the code runs every month and delete the files which are 25 months older.</description>
      <pubDate>Wed, 26 Apr 2017 00:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353531#M82527</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-26T00:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353533#M82528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32726"&gt;@SAS_INFO&lt;/a&gt; wrote:&lt;BR /&gt;Ideally the code needs to delete the file which is 24 months older and to be in safer side we are deleting any dataset older than 25 months.&lt;BR /&gt;&lt;BR /&gt;so the code runs every month and delete the files which are 25 months older.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does that have to do with the code you proposed and what I said was incorrect? Try running your code with a date in January and examine the output yourself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 00:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353533#M82528</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-26T00:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353534#M82529</link>
      <description>currently I have files only from 2015march</description>
      <pubDate>Wed, 26 Apr 2017 00:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353534#M82529</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-26T00:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353536#M82530</link>
      <description>&lt;P&gt;So then you haven't tested it with January yet &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 01:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353536#M82530</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-26T01:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353546#M82535</link>
      <description>NOPE &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Wed, 26 Apr 2017 02:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353546#M82535</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-26T02:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353549#M82538</link>
      <description>nothing was incorrect in ur code, just a change I made</description>
      <pubDate>Wed, 26 Apr 2017 03:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353549#M82538</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-26T03:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353551#M82539</link>
      <description>&lt;P&gt;&amp;nbsp;OLDEST_ALLOWED=put(intnx('month',today(),-25),yymmn6.);&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 03:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353551#M82539</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-04-26T03:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353991#M82712</link>
      <description>&lt;P&gt;Hi Reez,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your code,used libname concat, but it deleted only the first libname, location file, and rest dint get deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; A &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'/data/test1/a1/DATASET'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; B &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'/data/test2/a2/DATASET'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; C &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'/data/test3/a3/DATASET'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CONCAT (A B C );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; table=;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;OLDEST_ALLOWED=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'catt(year(today())-2,"_",month(today())-2)'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(symget(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'table'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;RC=dosubl( &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'data _null_;'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'call symputx("table"," ");'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'set SASHELP.VSTABLE; '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'where LIBNAME="CONCAT" and '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'trim(MEMNAME) like "%20____" and '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'substr(MEMNAME, length(MEMNAME)-5,6) &amp;lt;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ||quote(OLDEST_ALLOWED)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;';call symputx("table",MEMNAME); stop; run;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; lengthn(symget(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'table'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;CR=dosubl( &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'proc delete data=CONCAT.'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||symget(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'table'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;';run;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 06:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/353991#M82712</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-27T06:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/354071#M82760</link>
      <description>&lt;P&gt;I did say your oldest_allowed was incorrect. Use Chris' version.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Month returns a value between 1 and 12. If it's January your second term will edd up negative.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 12:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/354071#M82760</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-27T12:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro in libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/354335#M82877</link>
      <description>hi Reeza,&lt;BR /&gt;&lt;BR /&gt;I made the change in oldest_allowed. but still its not deleteing satasets.&lt;BR /&gt;&lt;BR /&gt;Please Note, when I executed the code for the first time, it deleted the datasets.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;libname A '/data/test1/a1/DATASET';&lt;BR /&gt;libname B '/data/test2/a2/DATASET';&lt;BR /&gt;libname C '/data/test3/a3/DATASET';&lt;BR /&gt;&lt;BR /&gt;libname CONCAT (A B C );&lt;BR /&gt;&lt;BR /&gt;%let table=;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;OLDEST_ALLOWED=put(intnx('month',today(),-25),yymmn6.);&lt;BR /&gt;&lt;BR /&gt;do until(symget('table')=' ');&lt;BR /&gt;RC=dosubl( 'data _null_;'&lt;BR /&gt;||'call symputx("table"," ");'&lt;BR /&gt;||'set SASHELP.VSTABLE; '&lt;BR /&gt;||'where LIBNAME="CONCAT" and '&lt;BR /&gt;||'trim(MEMNAME) like "%20____" and '&lt;BR /&gt;||'substr(MEMNAME, length(MEMNAME)-5,6) &amp;lt;' ||quote(OLDEST_ALLOWED)&lt;BR /&gt;||';call symputx("table",MEMNAME); stop; run;');&lt;BR /&gt;if lengthn(symget('table')) then&lt;BR /&gt;CR=dosubl( 'proc delete data=CONCAT.'||symget('table')||';run;');&lt;BR /&gt;end;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 28 Apr 2017 04:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-in-libname/m-p/354335#M82877</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-28T04:44:04Z</dc:date>
    </item>
  </channel>
</rss>

