<?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: Get the max date of a file in the directory in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140350#M37516</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="5253" data-username="Astounding" href="https://communities.sas.com/people/Astounding" id="jive-52534505613653444786"&gt;Astounding&lt;/A&gt;, it will be used in Unix and also Windows. But what is the difference? Fow now i'm just using Unix (its more urgency).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Nov 2013 19:13:31 GMT</pubDate>
    <dc:creator>Augusto</dc:creator>
    <dc:date>2013-11-12T19:13:31Z</dc:date>
    <item>
      <title>Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140348#M37514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be very grateful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to get the most updated file from a directory to infile as data set;&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in the directory HAVE i have the following files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE201310.TXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE201311.TXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE201312.TXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE201309.TXT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I WANT infile only the HAVE201312.TXT file (is the most updated file)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Augusto Souza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 18:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140348#M37514</guid>
      <dc:creator>Augusto</dc:creator>
      <dc:date>2013-11-12T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140349#M37515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What operating system?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 18:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140349#M37515</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-11-12T18:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140350#M37516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="5253" data-username="Astounding" href="https://communities.sas.com/people/Astounding" id="jive-52534505613653444786"&gt;Astounding&lt;/A&gt;, it will be used in Unix and also Windows. But what is the difference? Fow now i'm just using Unix (its more urgency).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 19:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140350#M37516</guid>
      <dc:creator>Augusto</dc:creator>
      <dc:date>2013-11-12T19:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140351#M37517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I'm picturing a solution that issues an operating system command to obtain a list of the file names.&amp;nbsp; For example, in Unix a SAS program might contain this statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec ls /folder/path/have*.txt &amp;gt; /folder/path/list_of_have_files.txt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would create a file holding a list of all the files that you need to search.&amp;nbsp; It would be a simple matter to read those into a SAS data set, and extract the latest name:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have_files;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile "/folder/path/list_of_have_files.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length path $200;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input path $ &amp;amp;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have_files;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by descending path;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have_files (obs=1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('file_i_want', path);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;But the operating system command to get a list of files would vary by operating system.&amp;nbsp; So here's the Unix example ... I expect you would use a "dir" command under Windows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 19:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140351#M37517</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-11-12T19:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140352#M37518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Astounding... it worked perfectly...thanks to much for your help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 19:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140352#M37518</guid>
      <dc:creator>Augusto</dc:creator>
      <dc:date>2013-11-12T19:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140353#M37519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To find the most recent file on Unix you can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; infile 'ls -t | head -1' pipe ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; call symputx('lastfile',_infile_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;To find the most recent file on Windows you can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; infile 'dir /od /b' pipe end=eof;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&amp;nbsp; if eof then call symputx('lastfile',_infile_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 20:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140353#M37519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-11-12T20:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140354#M37520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'dir C:\TEMP\forum\test/o-d /b' pipe obs=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('last',_infile_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 21:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140354#M37520</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-11-12T21:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140355#M37521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, Linlin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's definitely elegant code, worthy of being noted.&amp;nbsp; That being said, I have a bias toward putting the list into a file, rather than piping it in, for two reasons.&amp;nbsp; The list serves as documentation as to what files were available when the program ran, and it can help in debugging if the results are not as expected.&amp;nbsp; Usually I extend the logic so that the list automatically follows the program around.&amp;nbsp; For example, if the program is prog1.sas, the list might be saved as prog1.have_filelist.&amp;nbsp; It's not too much work for macro language to capture the program name and automatically create a matching output file. Shameless plug time:&amp;nbsp; I wrote up details in chapter 13 of the SAS Press book &lt;SPAN style="text-decoration: underline;"&gt;SAS Macro Language Magic&lt;/SPAN&gt;.&amp;nbsp; Thanks for adding to my knowledge base.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 00:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140355#M37521</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-11-13T00:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140356#M37522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The big problem with using %SYSEXEC or X commands is that it is much more likely that any unexpected error messages from the command are going to be lost.&amp;nbsp; If instead you nest the operating system command into a data step you can get control of those messages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to create a file from the input of a piped operating system command then you can use SAS code for that also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'dir' pipe ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file 'dir.list' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put _infile_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 00:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140356#M37522</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-11-13T00:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140357#M37523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for participating. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 17:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140357#M37523</guid>
      <dc:creator>Augusto</dc:creator>
      <dc:date>2013-11-13T17:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get the max date of a file in the directory</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140358#M37524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have same issue but I have files in SAS library/folder how can i use this code. pls help me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 08:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Get-the-max-date-of-a-file-in-the-directory/m-p/140358#M37524</guid>
      <dc:creator>chirumalla</dc:creator>
      <dc:date>2014-02-07T08:29:51Z</dc:date>
    </item>
  </channel>
</rss>

