<?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: Extract date macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506359#M135732</link>
    <description>&lt;P&gt;That double quotes are necessary should be clear to you since &lt;STRONG&gt;2015-12-16&lt;/STRONG&gt;: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Understanding-of-macro-quotes-and-ampersand/td-p/239482" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Understanding-of-macro-quotes-and-ampersand/td-p/239482&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Oct 2018 07:38:55 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-10-22T07:38:55Z</dc:date>
    <item>
      <title>Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506354#M135730</link>
      <description>&lt;P&gt;I've a macro variable and it resolves to date value as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN:  Macro variable FIRSTDAYOFREPORTINGMONTH resolves to 01SEP2018
24         %put FirstDayofReportingMonth = &amp;amp;FirstDayofReportingMonth;
FirstDayofReportingMonth = 01SEP2018
25         %put LastDayofReportingMonth  = &amp;amp;LastDayofReportingMonth;
SYMBOLGEN:  Macro variable LASTDAYOFREPORTINGMONTH resolves to 30SEP2018
LastDayofReportingMonth  = 30SEP2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now I need to extract the data based on date value and I should not hard code the date value. Therefore I tried to to filter the data with the use of macros, but I'm getting the error as mentioned below. Appreciate if someone of you tell me to know to extract the data with the help of date macro.&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*ERROR-1*/

68         /*      where KNDTOP between '01sep2018'd and '30sep2018'd*/
69         	  where KNDTOP between &amp;amp;FirstDayofReportingMonth. and &amp;amp;LastDayofReportingMonth.
SYMBOLGEN:  Macro variable FIRSTDAYOFREPORTINGMONTH resolves to 01SEP2018
SYMBOLGEN:  Macro variable LASTDAYOFREPORTINGMONTH resolves to 30SEP2018
NOTE 138-205: Line generated by the macro variable "FIRSTDAYOFREPORTINGMONTH".
69          01SEP2018
              _______
              22
ERROR 22-322: Syntax error, expecting one of the following: !!, *, **, +, -, /, AND, ||.  

/*ERROR-2*/


68         /*      where KNDTOP between '01sep2018'd and '30sep2018'd*/
69         	  where KNDTOP between '&amp;amp;FirstDayofReportingMonth.'d and '&amp;amp;LastDayofReportingMonth.'d
ERROR: Invalid date/time/datetime constant '&amp;amp;FirstDayofReportingMonth.'d.
ERROR: Invalid date/time/datetime constant '&amp;amp;LastDayofReportingMonth.'d.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 06:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506354#M135730</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-22T06:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506356#M135731</link>
      <description>&lt;P&gt;You need double quotes!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where KNDTOP between "&amp;amp;FirstDayofReportingMonth."d and "&amp;amp;LastDayofReportingMonth."d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 07:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506356#M135731</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-10-22T07:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506359#M135732</link>
      <description>&lt;P&gt;That double quotes are necessary should be clear to you since &lt;STRONG&gt;2015-12-16&lt;/STRONG&gt;: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Understanding-of-macro-quotes-and-ampersand/td-p/239482" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Understanding-of-macro-quotes-and-ampersand/td-p/239482&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 07:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506359#M135732</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-22T07:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506434#M135770</link>
      <description>&lt;P&gt;If my macro variable resolves to&amp;nbsp;20180630, I'm unable to resolve this with double quotes. See the error below. May I know what I'm missing here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;7262             and F_CLM_CLAIM_EOM.REPORTING_DATE_SK = "&amp;amp;LASTDAYOFREPORTINGMONTH."d
SYMBOLGEN:  Macro variable LASTDAYOFREPORTINGMONTH resolves to 20180630
ERROR: Invalid date/time/datetime constant "20180630"d.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 13:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506434#M135770</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-22T13:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506438#M135773</link>
      <description>&lt;P&gt;It is invalid to create a date value of "20180630"d.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is valid to create a date value of "30JUN2018"d.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus, you should be creating macro variables that have values formatted as 30JUN2018, or better yet (this is the preferred solution) don't use formatted dates here, just use that actual date value, unformatted, and you won't need double quotes and you won't need the letter d after the final double quote. Formats are so humans can understand the date value; SAS doesn't need this, and so it is a waste of time to format the values so humans can read it and then "unformat it" by putting the date in double quotes with the letter d after it.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506438#M135773</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-22T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506439#M135774</link>
      <description>&lt;P&gt;Do a google search for "sas date literals", and study the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've been told about this here on the communities repeatedly, eg in &lt;A href="https://communities.sas.com/t5/SAS-Programming/Date-variable-calculation/td-p/425702" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Date-variable-calculation/td-p/425702&lt;/A&gt; and &lt;A href="https://communities.sas.com/t5/SAS-Programming/Char-to-num-for-DATE/td-p/497722" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Char-to-num-for-DATE/td-p/497722&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your memory is THAT leaky, you should consider other endeavors than working with SAS, as it requires one to keep at least the important things that were learned once.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 13:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-macro-variable/m-p/506439#M135774</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-22T13:57:04Z</dc:date>
    </item>
  </channel>
</rss>

