<?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: check for the latest file while run in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444725#M111378</link>
    <description>i want to read .xlsx file with latest modified time.</description>
    <pubDate>Mon, 12 Mar 2018 13:04:35 GMT</pubDate>
    <dc:creator>anirudhs</dc:creator>
    <dc:date>2018-03-12T13:04:35Z</dc:date>
    <item>
      <title>check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444685#M111374</link>
      <description>&lt;P&gt;Hi looking for code which can check for the latest file based on its created date and time, if it find latest file then it should execute the process flow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hint: the file can be of any sas readable format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg. if a.xlx was last modified/created Today's date at 3:13 pm then it should import and execute.&lt;/P&gt;&lt;P&gt;if not updated then ...it should terminate the execution.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444685#M111374</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-12T09:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444689#M111375</link>
      <description>&lt;P&gt;First, using file data/time is not a good way of doing any process - it can easily be modified.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, define "SAS readable" as SAS can read almost any file type.&amp;nbsp; What are the specifications for the process, what do you have written down in the functional design definition for the process.&amp;nbsp; What agreement do you have on what data will be given?&amp;nbsp; Just saying you want to do something on anything that appears is not going to work, ever.&amp;nbsp; Clear process, clear documentation, fixed inputs, fixed outputs.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444689#M111375</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-12T09:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444725#M111378</link>
      <description>i want to read .xlsx file with latest modified time.</description>
      <pubDate>Mon, 12 Mar 2018 13:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444725#M111378</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-12T13:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444735#M111382</link>
      <description>&lt;P&gt;Assuming your on Windows:&lt;/P&gt;
&lt;PRE&gt;filename tmp pipe 'dir "yourdirectory/*.xlsx" /b /o-d';

data _null_;
  infile tmp dlm="¬";
  if _n_=1 then call execute('proc import datafile='||strip(_infile_)||' out=want; run;');
run;&lt;/PRE&gt;
&lt;P&gt;This will use DOS to return a list of files sorted by date reversed, then on first one generate a proc import statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said, your code will fall over each run, the process is way to vague, Excel is a poor data medium.&amp;nbsp; What happens if they post a file called xlsx but its not, or not in the right form, or don't post the file, or put a picture in it...&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 13:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444735#M111382</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-12T13:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444737#M111384</link>
      <description>Yes im on windows and surely i will try for the same.</description>
      <pubDate>Mon, 12 Mar 2018 13:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444737#M111384</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-12T13:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444747#M111389</link>
      <description>&lt;P&gt;This code will read a directory and find the creation times for .xlsx files:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename indir '&amp;lt;directory&amp;gt;';
data test;
  dirid=dopen('indir');
  do filenum=1 to dnum(dirid);
    name=dread(dirid,filenum);
    if upcase(scan(name,-1,'.')) ne 'XLSX' then
      continue;
    fileid=mopen(dirid,name);
    if fileid=0 then do;
      put _all_;
      continue;
      end;
    Created=finfo(fileid,'Create Time');
    output;
    rc=fclose(fileid);
    end;
  keep name created;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The created variable will be a datetime, but formatted according to your national language settings in Windows, you then have to find the correct informat for reading it into a numeric datetime. After that, it should be as simple as to sort by the date and take the last record.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 13:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/444747#M111389</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-03-12T13:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445025#M111475</link>
      <description>i dont want the last record by date or time .... i want to read the file only when it is modified where the windows updates the date and time when the file is modified ..so if the file is not modified then it should not read it.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2018 04:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445025#M111475</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-13T04:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445068#M111485</link>
      <description>So you need a datetime with the last run of the process to have something to compare the files modification date to. Where do you store that information?</description>
      <pubDate>Tue, 13 Mar 2018 07:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445068#M111485</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-03-13T07:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: check for the latest file while run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445076#M111486</link>
      <description>No sir,&lt;BR /&gt;when i will hit the run in EG to run the code for importing the .xlsx file then at that time if the xlsx file in the derictory has modified date/time then it should import. If it finds the last run time/date then it should not run ..it should terminate with msg : old file.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2018 08:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-for-the-latest-file-while-run/m-p/445076#M111486</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-03-13T08:02:18Z</dc:date>
    </item>
  </channel>
</rss>

