<?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: Proc Import - Last Run file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602069#M174274</link>
    <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0js70lrkxo6uvn1fl4a5aafnlgt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0js70lrkxo6uvn1fl4a5aafnlgt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd use something like this macro to get all of the filenames in your directory with the xls extension. From there you would need to determine how to extract the most recent file (based on your naming convention) and then take that result and throw it into a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Start by taking the macro in that link and running something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%list_files(&lt;SPAN&gt;E:\Processing\Orders&lt;/SPAN&gt;,xls)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And let's see the output (assuming it's safe to share).&lt;/P&gt;</description>
    <pubDate>Wed, 06 Nov 2019 17:29:23 GMT</pubDate>
    <dc:creator>unison</dc:creator>
    <dc:date>2019-11-06T17:29:23Z</dc:date>
    <item>
      <title>Proc Import - Last Run file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602059#M174267</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a proc import and import a csv from a previous run. I have an excel file of which is date stamped&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;P&gt;All_Order_0219&lt;/P&gt;
&lt;P&gt;All_Order_0619&lt;/P&gt;
&lt;P&gt;All_Order_0719&lt;/P&gt;
&lt;P&gt;All_Order_0919&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, there isn't a file for each month as the code is run on an ad-hoc basis and currently, I manually update my PROC IMPORT to reference the most recent file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am trying to do is avoid the user from having to manually state which file to import (below) and ideally, I'd like my code to look at the most recent file and automatically import, is there anyway of doing this please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Import&lt;BR /&gt;Datafile='E:\Processing\Orders\All_Order&lt;STRONG&gt;_0919&lt;/STRONG&gt;.xls'&lt;BR /&gt;Out=Work.All_Order_Previous_Run&lt;BR /&gt;DBMS=XLS &lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 16:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602059#M174267</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-11-06T16:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - Last Run file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602069#M174274</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0js70lrkxo6uvn1fl4a5aafnlgt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0js70lrkxo6uvn1fl4a5aafnlgt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd use something like this macro to get all of the filenames in your directory with the xls extension. From there you would need to determine how to extract the most recent file (based on your naming convention) and then take that result and throw it into a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Start by taking the macro in that link and running something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%list_files(&lt;SPAN&gt;E:\Processing\Orders&lt;/SPAN&gt;,xls)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And let's see the output (assuming it's safe to share).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 17:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602069#M174274</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-06T17:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - Last Run file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602234#M174324</link>
      <description>&lt;P&gt;Step #1: reverse the order of the date in your filenames (YYMM instead of MMYY). That simplifies the solution by at least 50%.&lt;/P&gt;
&lt;P&gt;Maxim 33: Intelligent Data Makes for Intelligent Programs (is also true for filenames).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 21:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Last-Run-file/m-p/602234#M174324</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-06T21:49:49Z</dc:date>
    </item>
  </channel>
</rss>

