<?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 How to choose the latest date on a file where there is a Macro that sets the date for current in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771137#M30938</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a code that contains a macro for a date to always choose the current month. However the code uses a file that gets updated quarterly so that means unless I change the date manually it wont find the latest date file. I think a do loop macro can help? Any ideas?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro wrapper;&lt;BR /&gt;%if &amp;amp;pdefadjrun=1 %then %do;&lt;BR /&gt;%if %sysfunc(exist( file_name_&amp;amp;ReportDateYMD. ))^=1&lt;BR /&gt;%then %do;&lt;BR /&gt;%put NOTE: file_name_&amp;amp;ReportDateYMD. dataset does not exist;&lt;BR /&gt;%end;&lt;BR /&gt;%else %if %sysfunc(exist(file_name_&amp;amp;ReportDateYMD. ))=1&lt;BR /&gt;%then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Sep 2021 13:59:00 GMT</pubDate>
    <dc:creator>Hiandbye</dc:creator>
    <dc:date>2021-09-29T13:59:00Z</dc:date>
    <item>
      <title>How to choose the latest date on a file where there is a Macro that sets the date for current</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771137#M30938</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a code that contains a macro for a date to always choose the current month. However the code uses a file that gets updated quarterly so that means unless I change the date manually it wont find the latest date file. I think a do loop macro can help? Any ideas?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro wrapper;&lt;BR /&gt;%if &amp;amp;pdefadjrun=1 %then %do;&lt;BR /&gt;%if %sysfunc(exist( file_name_&amp;amp;ReportDateYMD. ))^=1&lt;BR /&gt;%then %do;&lt;BR /&gt;%put NOTE: file_name_&amp;amp;ReportDateYMD. dataset does not exist;&lt;BR /&gt;%end;&lt;BR /&gt;%else %if %sysfunc(exist(file_name_&amp;amp;ReportDateYMD. ))=1&lt;BR /&gt;%then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 13:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771137#M30938</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-09-29T13:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose the latest date on a file where there is a Macro that sets the date for current</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771141#M30939</link>
      <description>&lt;P&gt;I have to say that I am not sure I understand what you are asking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please describe the problem from scratch. Don't discuss code or macros, just describe what you are trying to do in words.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 14:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771141#M30939</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-29T14:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose the latest date on a file where there is a Macro that sets the date for current</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771143#M30940</link>
      <description>Thanks! I may have not explained this well. The macro in the code sets the current date but the above code uses a file that updates every quarter. So for example if I want to run this for today I will have to change the &amp;amp;ReportDateYMD to the latest available date file. Is there a way where SAS can find and use the latest available file no matter the current date macro?&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Wed, 29 Sep 2021 14:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771143#M30940</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-09-29T14:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose the latest date on a file where there is a Macro that sets the date for current</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771144#M30941</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357957"&gt;@Hiandbye&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks! I may have not explained this well. The macro in the code sets the current date but the above code uses a file that updates every quarter. So for example if I want to run this for today I will have to change the &amp;amp;ReportDateYMD to the latest available date file. Is there a way where SAS can find and use the latest available file no matter the current date macro?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Read in all file names in the folder into a SAS data set. (There are plenty of posts here in the SAS Communities which give the code to do this)&lt;/LI&gt;
&lt;LI&gt;Parse the file names to extract the name of the file with the most recent date.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;All of this can be done in SAS data steps. No macros needed.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 14:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-choose-the-latest-date-on-a-file-where-there-is-a-Macro/m-p/771144#M30941</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-29T14:27:21Z</dc:date>
    </item>
  </channel>
</rss>

