<?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 Set dataset based on the date in file name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290416#M60110</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to automatically set the dataset with the newest date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a folder / directory which contains &lt;SPAN&gt;datasets&lt;/SPAN&gt; with a date in the file name. The date indicates when &lt;SPAN&gt;the dataset&lt;/SPAN&gt; is generated. It could for instance be called a_08AUG16 or a_09AUG16. I want to be able to set the latest &lt;SPAN&gt;dataset automatically&lt;/SPAN&gt; based on the date in the file name. Is that possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aske&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2016 10:53:32 GMT</pubDate>
    <dc:creator>Aske</dc:creator>
    <dc:date>2016-08-09T10:53:32Z</dc:date>
    <item>
      <title>Set dataset based on the date in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290416#M60110</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to automatically set the dataset with the newest date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a folder / directory which contains &lt;SPAN&gt;datasets&lt;/SPAN&gt; with a date in the file name. The date indicates when &lt;SPAN&gt;the dataset&lt;/SPAN&gt; is generated. It could for instance be called a_08AUG16 or a_09AUG16. I want to be able to set the latest &lt;SPAN&gt;dataset automatically&lt;/SPAN&gt; based on the date in the file name. Is that possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aske&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 10:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290416#M60110</guid>
      <dc:creator>Aske</dc:creator>
      <dc:date>2016-08-09T10:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Set dataset based on the date in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290418#M60112</link>
      <description>&lt;P&gt;Let me start by saying its never a good idea to put "data" into the structural part of the dataset - either table details or column details, it makes programming so much harder, and runs up problems like this. &amp;nbsp;Put data in the rows of the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you can use the metadata files from sashelp.vtable, basically that has the structural parts as data elements. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _20JAN2016;
  set sashelp.class;
run;
data _14FEB2016;
  set sashelp.cars;
run;

proc sql noprint;
  select  put(max(DTE),date9.)
  into    :DTE
  from    (select *,input(strip(compress(MEMNAME,"_","")),date9.) as DTE from SASHELP.VTABLE where libname="WORK" and substr(MEMNAME,1,1)="_");
quit;

data want;
  set work._&amp;amp;DTE.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 11:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290418#M60112</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-09T11:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Set dataset based on the date in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290419#M60113</link>
      <description>&lt;P&gt;The best solution, hands down, is to use a date format in the dataset names that sorts itself, ie YYYY-MM-DD.&lt;/P&gt;
&lt;P&gt;With the current situation, you will have to read the dataset names from sashelp.vtable (or dictionary.tables), convert the date in the dataset name to a SAS date, and retrieve the wanted observation with max(date).&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 11:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290419#M60113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-09T11:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set dataset based on the date in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290432#M60115</link>
      <description>&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 12:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-dataset-based-on-the-date-in-file-name/m-p/290432#M60115</guid>
      <dc:creator>Aske</dc:creator>
      <dc:date>2016-08-09T12:19:16Z</dc:date>
    </item>
  </channel>
</rss>

