<?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: Macronot working to workout the latest file (by the date on the end of the file name) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565170#M158640</link>
    <description>&lt;P&gt;It looks like maxid never gets populated.&lt;/P&gt;
&lt;P&gt;so the preceding data step before probably doesn't run as expected.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2019 10:43:44 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-06-11T10:43:44Z</dc:date>
    <item>
      <title>Macronot working to workout the latest file (by the date on the end of the file name)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565165#M158635</link>
      <description>&lt;P&gt;Hi all I am trying to import the latest created file by the data at the end of it's name form a location. I have the below code that I am sure used to work but I am now getting an error (also provided below), can anyone assist and tell me what's wrong with the Macro as I can't work it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; location = \\Drive and file location entered here\file name here;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Code being run&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; get_filenames(location);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;filename _dir &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"%bquote(&amp;amp;location.)"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data filenames(keep=memname SeqNo Extention );&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Excel_Dir=dopen( &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"_dir"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if Excel_Dir &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do;&lt;/P&gt;&lt;P&gt;count=dnum(Excel_Dir);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; to count;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;memname=dread(Excel_Dir,i);&lt;/P&gt;&lt;P&gt;SeqNo =i;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Extention = substr(memname,index(memname,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,length(memname));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if Extention = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"txt"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Extention = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"txt"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output filenames;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;rc=dclose(Excel_Dir);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"MaxID"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,SeqNo);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Extention"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,Extention);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%DO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; j = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%TO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;MaxID.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set work.filenames;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where SeqNo = &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;j.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"inputfile"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,memname);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Position"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,(length(memname)-(length(Extention)+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; get_filenames;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Create a stamp (set as todays date) */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FORMAT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Stamp &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Stamp = put(today(),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CALL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Stamp'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,Stamp);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Stamp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;get_filenames&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%bquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;("&amp;amp;location."));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Select the name of the latest file by the max SeqNo */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;NOPRINT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; compress(memname) &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INTO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;: fileName&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; filenames&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SeqNo &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; max(SeqNo) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; filenames)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;QUIT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;fileName. ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error I am receiving&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;/P&gt;&lt;P&gt;&amp;amp;MaxID.&lt;/P&gt;&lt;P&gt;ERROR: The %TO value of the %DO J loop is invalid.&lt;/P&gt;&lt;P&gt;ERROR: The macro GET_FILENAMES will stop executing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what could be wrong with the above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 10:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565165#M158635</guid>
      <dc:creator>DC2-CJH</dc:creator>
      <dc:date>2019-06-11T10:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macronot working to workout the latest file (by the date on the end of the file name)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565166#M158636</link>
      <description>Don't worry resolved it, thanks</description>
      <pubDate>Tue, 11 Jun 2019 10:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565166#M158636</guid>
      <dc:creator>DC2-CJH</dc:creator>
      <dc:date>2019-06-11T10:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macronot working to workout the latest file (by the date on the end of the file name)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565170#M158640</link>
      <description>&lt;P&gt;It looks like maxid never gets populated.&lt;/P&gt;
&lt;P&gt;so the preceding data step before probably doesn't run as expected.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 10:43:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macronot-working-to-workout-the-latest-file-by-the-date-on-the/m-p/565170#M158640</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-06-11T10:43:44Z</dc:date>
    </item>
  </channel>
</rss>

