<?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: Date constant in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732559#M228280</link>
    <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798" target="_blank" rel="noopener"&gt;nickspencer,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use the following code to generate SAS internal date value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mydate = %sysfunc(inputn(01jan2021,date9.));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The value of &amp;amp;mydate will be an internal SAS date value 22281 (equal to the number of days from 01jan1960).&lt;/P&gt;
&lt;P&gt;Then you can refer to it in your code as &amp;amp;mydate without quotes and letter d at the end.&lt;BR /&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Apr 2021 17:09:40 GMT</pubDate>
    <dc:creator>LeonidBatkhan</dc:creator>
    <dc:date>2021-04-09T17:09:40Z</dc:date>
    <item>
      <title>Date constant in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732548#M228272</link>
      <description>Hello everyone,&lt;BR /&gt;Is it correct to use date constant in %let statement? I will be using this value only to filter the data in a datastep later on.&lt;BR /&gt;&lt;BR /&gt;%let mydate=‘01jan2021’d;&lt;BR /&gt;&lt;BR /&gt;data test1;&lt;BR /&gt;set test ;&lt;BR /&gt;If dt=&amp;amp;mydate;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Please let me know your thoughts.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Nick</description>
      <pubDate>Fri, 09 Apr 2021 16:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732548#M228272</guid>
      <dc:creator>nickspencer</dc:creator>
      <dc:date>2021-04-09T16:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date constant in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732551#M228274</link>
      <description>&lt;P&gt;That will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question to ask is whether once the macro processor has finished converting the text do you have valid SAS syntax.&amp;nbsp; You can test it be replacing the macro variable reference with the text the macro variable contains.&amp;nbsp; (You should do this in your head as you are writing SAS code that uses macro variable references.)&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 16:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732551#M228274</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-09T16:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Date constant in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732557#M228279</link>
      <description>&lt;P&gt;There are style choices involved.&lt;/P&gt;
&lt;P&gt;Your code should work&amp;nbsp;&lt;STRONG&gt;after&lt;/STRONG&gt; you fix the curly quotes in your %let statement, with a simple example like this. &lt;/P&gt;
&lt;P&gt;%let mydate=&lt;FONT size="6" color="#FF0000"&gt;‘&lt;/FONT&gt;01jan2021&lt;FONT size="6" color="#FF0000"&gt;’&lt;/FONT&gt;d;&lt;/P&gt;
&lt;P&gt;You must use simple ' quote marks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I, again I will say as a style choice, dislike quotes in macro variables I create with %Let for dates and would use in this case:&lt;/P&gt;
&lt;PRE&gt;%let mydate=01jan2021;

data test1;
   set test ;
   If dt= "&amp;amp;mydate."d;
Run;&lt;/PRE&gt;
&lt;P&gt;Using the date literal version in the IF statement makes it clear that the intended value that MYDATE should contain is a date literal. So debugging may be easier.&amp;nbsp; Plus I could then use Mydate in something like a title statement: Title "This report was generated for &amp;amp;mydate.";&lt;/P&gt;
&lt;P&gt;or labels for a variable : label thisvar = "Measured as of &amp;amp;mydate.";&lt;/P&gt;
&lt;P&gt;or in a filename: ods rtf file="&amp;lt;path&amp;gt;/reportfile &amp;amp;mydate..rtf";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 16:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732557#M228279</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-09T16:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date constant in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732559#M228280</link>
      <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798" target="_blank" rel="noopener"&gt;nickspencer,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use the following code to generate SAS internal date value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mydate = %sysfunc(inputn(01jan2021,date9.));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The value of &amp;amp;mydate will be an internal SAS date value 22281 (equal to the number of days from 01jan1960).&lt;/P&gt;
&lt;P&gt;Then you can refer to it in your code as &amp;amp;mydate without quotes and letter d at the end.&lt;BR /&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 17:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-constant-in-macro/m-p/732559#M228280</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2021-04-09T17:09:40Z</dc:date>
    </item>
  </channel>
</rss>

