<?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: Identifying the most recent subfolder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/660131#M197636</link>
    <description>&lt;P&gt;First you can get list of all folders from that sub directory and then sort them ascending or descending by the folder name and pick the latest, based on last observation or first observation depending on how you sorted it, store it in a macro variable and use it. Hope this helps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Filename filelist pipe "dir /b /s &amp;lt;path&amp;gt;"; 
                                                                                   
   Data file_list;      
     length folder_name $8.;                                  
     Infile filelist truncover;
     Input filename $100.;
    *separator is set based on os / for unix and linux \ for windows;
     folder_name = input(scan(filename,-2,separator),best12.);
     Put filename=;
   Run; 
 
proc sql;
select folder_name into: foldername from file_list
where folder_name = max(folder_name);
quit;

Data file_list_to_process;      
    set file_list;
    if index(folder_name,"&amp;amp;foldername") &amp;gt; 0;
     Put filename=;
   Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jun 2020 18:11:14 GMT</pubDate>
    <dc:creator>smantha</dc:creator>
    <dc:date>2020-06-16T18:11:14Z</dc:date>
    <item>
      <title>Identifying the most recent subfolder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/660123#M197633</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to dynamically have my program grab a file in from a subfolder, so that I do not have to manually go into the program and update it every time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The directory structure is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main Folder&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20200501&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20200502&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20200503&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the program to look at the Modified Date of the folder and determine which one is the most recent.&amp;nbsp; I can then have SAS read the file from that subfolder.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 17:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/660123#M197633</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2020-06-16T17:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying the most recent subfolder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/660131#M197636</link>
      <description>&lt;P&gt;First you can get list of all folders from that sub directory and then sort them ascending or descending by the folder name and pick the latest, based on last observation or first observation depending on how you sorted it, store it in a macro variable and use it. Hope this helps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Filename filelist pipe "dir /b /s &amp;lt;path&amp;gt;"; 
                                                                                   
   Data file_list;      
     length folder_name $8.;                                  
     Infile filelist truncover;
     Input filename $100.;
    *separator is set based on os / for unix and linux \ for windows;
     folder_name = input(scan(filename,-2,separator),best12.);
     Put filename=;
   Run; 
 
proc sql;
select folder_name into: foldername from file_list
where folder_name = max(folder_name);
quit;

Data file_list_to_process;      
    set file_list;
    if index(folder_name,"&amp;amp;foldername") &amp;gt; 0;
     Put filename=;
   Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/660131#M197636</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-16T18:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying the most recent subfolder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/661798#M197766</link>
      <description>Thank you so much for the great suggestion!</description>
      <pubDate>Wed, 17 Jun 2020 15:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-most-recent-subfolder/m-p/661798#M197766</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2020-06-17T15:08:11Z</dc:date>
    </item>
  </channel>
</rss>

