<?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: Macro to Retrieve Current Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439535#M109687</link>
    <description>&lt;P&gt;The macro processor is a code&amp;nbsp;generator so the line of code you are executing returns a date which SAS then tries to execute and which is, of course, invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a macro to return today's date like a function then you could do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro currdate;
%let thisday=%qtrim(%qleft(%qsysfunc(date(),worddate18.)));
&amp;amp;thisday
%mend currdate;

%let myday=%currdate;
%put &amp;amp;myday;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course there's no need to do that since you can simply use the date function outside a macro anyway....&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 00:57:38 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2018-02-23T00:57:38Z</dc:date>
    <item>
      <title>Macro to Retrieve Current Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439529#M109682</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the macro below which I believe is correct, but I get the error message shown below. When I googled the error message, some authors said a semicolon was missing, but adding that still resulted in the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running SAS 9.4 and receive this error on both Base SAS and SAS EG.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise on how to avoid the error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro currdate;
%qtrim(%qleft(%qsysfunc(date(),worddate18.)));
%mend currdate;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 592px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18769i261A81550D18B451/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439529#M109682</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2018-02-23T00:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Retrieve Current Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439535#M109687</link>
      <description>&lt;P&gt;The macro processor is a code&amp;nbsp;generator so the line of code you are executing returns a date which SAS then tries to execute and which is, of course, invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a macro to return today's date like a function then you could do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro currdate;
%let thisday=%qtrim(%qleft(%qsysfunc(date(),worddate18.)));
&amp;amp;thisday
%mend currdate;

%let myday=%currdate;
%put &amp;amp;myday;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course there's no need to do that since you can simply use the date function outside a macro anyway....&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439535#M109687</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2018-02-23T00:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Retrieve Current Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439538#M109690</link>
      <description>&lt;P&gt;Your code works as intended and the macro call returns a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must use that string somehow, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let d = %currdate;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439538#M109690</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-02-23T01:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Retrieve Current Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439544#M109694</link>
      <description>&lt;P&gt;Thanks Chris.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-Retrieve-Current-Date/m-p/439544#M109694</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2018-02-23T01:09:23Z</dc:date>
    </item>
  </channel>
</rss>

