<?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 datasets older than 24 months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351527#M81816</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 Reeza,&lt;/P&gt;
&lt;P&gt;thank you for your reply.&lt;/P&gt;
&lt;P&gt;I have a doubt in the 3rd step you mentioned.&lt;BR /&gt;I cannot filter by date as this process needs to be automated, &lt;STRONG&gt;so I cannot manually keyin the date in the filter&lt;/STRONG&gt;, would you please share someother way&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That part in bold is incorrect, you can use the macro variable TODAY() to get todays date. Then using the INTCK or INTNX you can then decide which dates are more than 24 months old. Use SCAN() and INPUT() to extract the date from the filename.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2017 03:37:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-04-20T03:37:37Z</dc:date>
    <item>
      <title>Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348963#M80868</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a library , i have datasets for the past 24 months, i need to develop a piece of code that deletes the dataaset if it is older than 24 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for ex my datasets are named as follows&lt;/P&gt;&lt;P&gt;ab_2015jan&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;ab_2017jan&lt;/P&gt;&lt;P&gt;ab_2017feb&lt;/P&gt;&lt;P&gt;ab_2017mar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 03:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348963#M80868</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-11T03:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348966#M80869</link>
      <description>&lt;P&gt;1. Get list of all datasets in library. Use SASHELP.VTABLE&lt;/P&gt;
&lt;P&gt;2. Extract date component to calculate date&lt;/P&gt;
&lt;P&gt;3. Use proc SQL to store dataset names into macro variable filtering by date&lt;/P&gt;
&lt;P&gt;4. Use PROC datasets to delete datasets.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 04:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348966#M80869</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-11T04:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348969#M80871</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symput('to_delete',catt('ab_',year(today())-2,put(today(), monname3.)));
run;

proc delete data=work.&amp;amp;to_delete.;
run;

&lt;/PRE&gt;
&lt;P&gt;Of course, you'll have to change 'work' to the name of your library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 04:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348969#M80871</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-11T04:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348975#M80874</link>
      <description>&lt;P&gt;hi Reeza,&lt;/P&gt;&lt;P&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;I have a doubt in the 3rd step you mentioned.&lt;BR /&gt;I cannot filter by date as this process needs to be automated, so I cannot manually keyin the date in the filter, would you please share someother way&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 05:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348975#M80874</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-11T05:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348979#M80876</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The step , &amp;nbsp;year(today())-2 will delete all the datasets of 2015, but i need to do it month wise,&lt;/P&gt;&lt;P&gt;ex, after&amp;nbsp;starting &amp;nbsp;april 2017, the code should delete march2015 dataset.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 05:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348979#M80876</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-11T05:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348985#M80878</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32726"&gt;@SAS_INFO&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In a data step (or PROC SQL if you must) extract the date string from the table name, convert this date string to a SAS Date value and then use SAS calendarfunctions like INTNX() to determine which dates are older than two years based on todays date.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 06:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348985#M80878</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-11T06:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349108#M80936</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Deleting datasets older than 24 months

inspired by this post
https://goo.gl/z3BvtY
https://communities.sas.com/t5/Base-SAS-Programming/Deleting-datasets-older-than-24-months/m-p/348963


HAVE
====&lt;BR /&gt;
These SAS datasets in my work library

Member Name                             dte
-------------------------------------------
ONE                               11APR2017
POWER_ZIPCODES                    22APR2011 * greater than 24 months
SAMTF_FAC_4                       05APR2016
THREE                             11APR2017
TWO                               11APR2017
ZIP5ETHNIC                        24APR2011 * greater than 24 months


WANT (To delete SAS datsets greater then 24 months)
===================================================&lt;BR /&gt;
Delete these from work library

Member Name                             dte
-------------------------------------------
POWER_ZIPCODES                    22APR2011 * greater than 24 months
ZIP5ETHNIC                        24APR2011 * greater than 24 months


WORKING CODE
============

        proc sql
          intck("month",datepart(crdate),today()) &amp;gt; 24
        Dosubl
          delete &amp;amp;dsns ;

FULL SOLUTIONS

*                _              _       _
 _ __ ___   __ _| | _____    __| | __ _| |_ __ _
| '_ ` _ \ / _` | |/ / _ \  / _` |/ _` | __/ _` |
| | | | | | (_| |   &amp;lt;  __/ | (_| | (_| | || (_| |
|_| |_| |_|\__,_|_|\_\___|  \__,_|\__,_|\__\__,_|

;


proc datasets lib=work kill;
run;quit;

data one two three;
  set sashelp.class;
run;quit;

* older daatsets;
x "cd d:\lup";
x "move power_zipcodes.sas7bdat E:\saswork\wrk\_TD3624_BEAST_";
x "move zip5ethnic.sas7bdat E:\saswork\wrk\_TD3624_BEAST_";
x cd c:\utl;

*          _       _   _
 ___  ___ | |_   _| |_(_) ___  _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|

;

%symdel dsns rc sqlobs / nowarn;
data _null_;

 if _n_=0 then do;

    rc=%sysfunc(dosubl('
       proc sql;
          select
             memname
          into
             :dsns separated by " "
          from
             sashelp.vtable
          where
                libname="WORK"
            and  typemem="DATA"
            and  intck("month",datepart(crdate),today()) &amp;gt; 24
       ;quit;
    '));

  end;

  if (&amp;amp;sqlobs = 0) then do;
    put "** proc sql failed with  &amp;amp;sqlobs obs ** ";
    stop;
  end;

  rc=dosubl('
     proc datasets lib=work mt=data;
       delete &amp;amp;dsns ;
     run;quit;
  ');

  if rc ne 0 then do;
    put "** proc datsets failed **" rc=;
    stop;
  end;

 stop;

run;quit;




&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 13:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349108#M80936</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-11T13:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349119#M80938</link>
      <description>&lt;P&gt;You didn't look at the macro variable the code produced. If you ran it today it would try to delete just one file, namely:&lt;/P&gt;
&lt;P&gt;one with the name: al_2015apr, namely 24 months ago. However, if you want it to delete the month prior to that, instead, use:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symput('to_delete',catt('ab_',year(today())-2,
   put(intnx('month',today(),-1), monname3.)));
run;

%put &amp;amp;to_delete.;

proc delete data=work.&amp;amp;to_delete.;
run;
&lt;/PRE&gt;
&lt;P&gt;Of course you don't need the %put statement there, I just included it so that you could see the name of the file that would be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 14:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349119#M80938</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-11T14:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349147#M80951</link>
      <description>&lt;P&gt;&amp;lt;Pedantic mode:on&amp;gt; Your request is not to delete datasets older than 24 months, it is to delete data sets with a name element that is 24 months prior (assumed to today). Quite a different thing.&lt;/P&gt;
&lt;P&gt;I can create a data TODAY that is named ab_2015jan. The data set would not be 24 months old.&lt;/P&gt;
&lt;P&gt;&amp;lt;Pedantic mode:off&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 14:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349147#M80951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-11T14:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349678#M81156</link>
      <description>&lt;P&gt;yes, my datasets are named in such a way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code should delete the datset which are 24 months older(by name)&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 06:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/349678#M81156</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-13T06:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351486#M81803</link>
      <description>&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 libraries 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;develoment&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 and delete datasets&amp;nbsp;only the Dataset folder .&lt;/P&gt;&lt;P&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 00:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351486#M81803</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-20T00:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351523#M81814</link>
      <description>&lt;P&gt;There was a solution provided that you marked as correct but it looks like you've added to the question. Can you clarify what the current situation is and where you're having issues?&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;</description>
      <pubDate>Thu, 20 Apr 2017 03:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351523#M81814</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T03:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351527#M81816</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 Reeza,&lt;/P&gt;
&lt;P&gt;thank you for your reply.&lt;/P&gt;
&lt;P&gt;I have a doubt in the 3rd step you mentioned.&lt;BR /&gt;I cannot filter by date as this process needs to be automated, &lt;STRONG&gt;so I cannot manually keyin the date in the filter&lt;/STRONG&gt;, would you please share someother way&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That part in bold is incorrect, you can use the macro variable TODAY() to get todays date. Then using the INTCK or INTNX you can then decide which dates are more than 24 months old. Use SCAN() and INPUT() to extract the date from the filename.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 03:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351527#M81816</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T03:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351530#M81819</link>
      <description>&lt;P&gt;its a new request added to my previous question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;waht i asked was to delete datasets within a library whose name is older than 24 months,&lt;/P&gt;&lt;P&gt;now i need to do the same across 13 folders&lt;/P&gt;&lt;P&gt;for ex:&lt;/P&gt;&lt;P&gt;this is my folder structure:&lt;/P&gt;&lt;P&gt;/data/DEV/&amp;amp;iterm/DATASET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the &amp;amp;iterm should get replaced with 13 folder names,&lt;/P&gt;&lt;P&gt;like crc,dbt,mer,online,tbt,yrc,lop,kyt,ded,fsw,fgt,kjh,mnb&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am trying to create the macro variable using iterative do loop :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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; name_list=&amp;nbsp;crc,dbt,mer,online,tbt,yrc,lop,kyt,ded,fsw,fgt,kjh,mnb;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;aruna&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%local&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i next_name;&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; i=1;&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;%while&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;name_list, &amp;amp;i) ne );&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; next_name = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;name_list, &amp;amp;i);&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; i = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;i + 1);&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;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; aruna;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the code is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once this is resolved, i need to develop another code which should be able to delete all datasets which name is 24 months old&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 03:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351530#M81819</guid>
      <dc:creator>SAS_INFO</dc:creator>
      <dc:date>2017-04-20T03:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting datasets older than 24 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351534#M81821</link>
      <description>&lt;P&gt;Change your process then, the steps I illustrated still apply.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for the first step, instead use a different way to get all the subfolders, the documentation covers this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could either use the data from the macro above to process each folder separately or change it to delete datasets directly. If you have X command this could be a single macro entirely, modifying the sample above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Parse out date from file name/path&lt;/P&gt;
&lt;P&gt;2. Determine if its more than 24 months&lt;/P&gt;
&lt;P&gt;3. Execute SYSEXEC command with file path, if more than 24 months.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 03:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-datasets-older-than-24-months/m-p/351534#M81821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T03:50:36Z</dc:date>
    </item>
  </channel>
</rss>

