<?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: Read a filename dynamically in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782579#M249488</link>
    <description>What do you mean 'it seems not to work'. &lt;BR /&gt;What are you expecting to happen and what happens? &lt;BR /&gt;How are you using the filename and how does it not work?&lt;BR /&gt;Code and log helps.</description>
    <pubDate>Fri, 26 Nov 2021 17:39:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-11-26T17:39:19Z</dc:date>
    <item>
      <title>Read a filename dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782571#M249480</link>
      <description>Hi everyone!&lt;BR /&gt;I am trying to read the latest file from a folder.&lt;BR /&gt;&lt;BR /&gt;Requirements:&lt;BR /&gt;1) The folder stores files as:&lt;BR /&gt;log_26112021 123456.log&lt;BR /&gt;&lt;BR /&gt;2) The file format is the name_date numbers. There is a space between the date and the numbers.&lt;BR /&gt;&lt;BR /&gt;What I have done so far is:&lt;BR /&gt;filename log "&amp;amp;path.\log_%sysfunc(today(), ddmmyyN8.).log";&lt;BR /&gt;&lt;BR /&gt;What I want to do is to read the rest of the file name, whatever it is including the space and the numbers. Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!</description>
      <pubDate>Fri, 26 Nov 2021 17:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782571#M249480</guid>
      <dc:creator>Crt</dc:creator>
      <dc:date>2021-11-26T17:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Read a filename dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782575#M249484</link>
      <description>&lt;UL&gt;
&lt;LI&gt;Mismatched quotes&lt;/LI&gt;
&lt;LI&gt;* is the wildcard character&lt;/LI&gt;
&lt;LI&gt;I'm unsure of the behaviour of this code if it resolves to multiple files&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename log "&amp;amp;path.\log_%sysfunc(today(), ddmmyyN8.) *.log";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/407983"&gt;@Crt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi everyone!&lt;BR /&gt;I am trying to read the latest file from a folder.&lt;BR /&gt;&lt;BR /&gt;Requirements:&lt;BR /&gt;1) The folder stores files as:&lt;BR /&gt;log_26112021 123456.log&lt;BR /&gt;&lt;BR /&gt;2) The file format is the name_date numbers. There is a space between the date and the numbers.&lt;BR /&gt;&lt;BR /&gt;What I have done so far is:&lt;BR /&gt;filename log "&amp;amp;path.\log_%sysfunc(today(), ddmmyyN8.).log';&lt;BR /&gt;&lt;BR /&gt;What I want to do is to read the rest of the file name, whatever it is including the space and the numbers. Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 17:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782575#M249484</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-26T17:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Read a filename dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782578#M249487</link>
      <description>Thank you for your response.&lt;BR /&gt;&lt;BR /&gt;I have tried the * character, but it seems not to work.</description>
      <pubDate>Fri, 26 Nov 2021 17:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782578#M249487</guid>
      <dc:creator>Crt</dc:creator>
      <dc:date>2021-11-26T17:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Read a filename dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782579#M249488</link>
      <description>What do you mean 'it seems not to work'. &lt;BR /&gt;What are you expecting to happen and what happens? &lt;BR /&gt;How are you using the filename and how does it not work?&lt;BR /&gt;Code and log helps.</description>
      <pubDate>Fri, 26 Nov 2021 17:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782579#M249488</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-26T17:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read a filename dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782581#M249490</link>
      <description>&lt;P&gt;You can use a wildcard in the filename.&lt;/P&gt;
&lt;P&gt;You could just try to read ALL of the files that match the pattern.&amp;nbsp; You can use the FILENAME= option on the INFILE statement to find the name of the file you are reading.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data logs;
  length fname filename $200;
  infile "&amp;amp;path./log_%sysfunc(today(), ddmmyyN8.)*.log" filename=fname ;
  input;
  filename=fname;
  lineno+1;
  if filename ne lag(filename) then lineno=1;
  line=_infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Nov 2021 17:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-filename-dynamically/m-p/782581#M249490</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-26T17:51:08Z</dc:date>
    </item>
  </channel>
</rss>

