<?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: create a parameter of a date value within Macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-parameter-of-a-date-value-within-Macro-variable/m-p/479844#M286565</link>
    <description>&lt;P&gt;Do not use a format for your macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT INTNX('MONTH',MDY(quarter*3,1,year),0,'E') INTO :livd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or use your macro variable as a date literal if it is formatted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE DATEPART(the_date) = "&amp;amp;livd"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally, I prefer the first option, as it makes writing subsequent code easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS This is covered in Maxim 28.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 10:08:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-07-20T10:08:59Z</dc:date>
    <item>
      <title>create a parameter of a date value within Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-parameter-of-a-date-value-within-Macro-variable/m-p/479842#M286564</link>
      <description>&lt;P&gt;I've been through the forums and can't quite find anything that fits what I'm having an issue with, so apologies if this is a repost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to push a date into a global variable so I can call it within my program. Currently I&amp;nbsp;get the date from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL noprint;&lt;BR /&gt;SELECT INTNX('MONTH',MDY(quarter*3,1,year),0,'E') format=date9. INTO :livd&lt;BR /&gt;FROM HPIindex&lt;BR /&gt;WHERE year = (SELECT MAX(year) FROM HPIindex)&lt;BR /&gt;HAVING quarter = MAX(quarter);&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to apply this as a date it is coming out as a character string so throwing an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA dates;&lt;BR /&gt;SET date_table;&lt;BR /&gt;WHERE&amp;nbsp;DATEPART(the_date) = &amp;amp;livd;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "LIVD".&lt;BR /&gt;28 30JUN2018&lt;BR /&gt;_______&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR: Syntax error while parsing WHERE clause.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT,&lt;BR /&gt;NE, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to create the &amp;amp;livd variable as a date instead of a string? So basically producing '30JUN2018'd instead of 30JUN2018?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, any help appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 09:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-parameter-of-a-date-value-within-Macro-variable/m-p/479842#M286564</guid>
      <dc:creator>Seb_A_Sanders</dc:creator>
      <dc:date>2018-07-20T09:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: create a parameter of a date value within Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-parameter-of-a-date-value-within-Macro-variable/m-p/479844#M286565</link>
      <description>&lt;P&gt;Do not use a format for your macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT INTNX('MONTH',MDY(quarter*3,1,year),0,'E') INTO :livd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or use your macro variable as a date literal if it is formatted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE DATEPART(the_date) = "&amp;amp;livd"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally, I prefer the first option, as it makes writing subsequent code easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS This is covered in Maxim 28.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 10:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-parameter-of-a-date-value-within-Macro-variable/m-p/479844#M286565</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-20T10:08:59Z</dc:date>
    </item>
  </channel>
</rss>

