<?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: Using date macro variable in SQL procedure in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95205#M26933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro variables are all characters so you need to enclose the macro variable in quotes and add the literal at the end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; PFC.MOIS = "&amp;amp;max_date"dt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Dec 2012 18:47:59 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2012-12-10T18:47:59Z</dc:date>
    <item>
      <title>Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95202#M26930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I generally use this SQL procedure to create the table I want :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE SASUSER.test AS&lt;BR /&gt;SELECT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PFC.NOTRANSIT AS TRANSIT&lt;BR /&gt;FROM&amp;nbsp;&amp;nbsp; testlib.LST_CL AS PFC&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PFC.MOIS = '31OCT2012:00:00:00'dt&lt;BR /&gt;;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now since the month is always the latest month in the table I tought of adding the max date of this table in a variable :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;select max(MOIS) &lt;BR /&gt;into : max_date &lt;BR /&gt;from testlib.LST_CL AS PFC;&amp;nbsp; &lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now how do I use this variable in my SQL procedure? The following gives me an error :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE SASUSER.test2 AS&lt;BR /&gt;SELECT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PFC.NOTRANSIT AS TRANSIT&lt;BR /&gt;FROM&amp;nbsp;&amp;nbsp; testlib.LST_CL AS PFC&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PFC.MOIS = &amp;amp;max_date&lt;/P&gt;&lt;P&gt;;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the proper way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 15:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95202#M26930</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2012-12-10T15:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95203#M26931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What type of values are in MOIS, SAS Date, SAS datetime, string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What kind of result do you get from:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;max_date; when run after the first bit of Proc SQL code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 16:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95203#M26931</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-10T16:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95204#M26932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if my original post missed detail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the result of %put &amp;amp;max_date :&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;max_date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;31OCT2012:00:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;Not sure if this is recognized as SAS datetime or string.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;Hope you can help me with this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;Thank you for your help and time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 18:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95204#M26932</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2012-12-10T18:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95205#M26933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro variables are all characters so you need to enclose the macro variable in quotes and add the literal at the end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; PFC.MOIS = "&amp;amp;max_date"dt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 18:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95205#M26933</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-12-10T18:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95206#M26934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Exactly what I was looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 22:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95206#M26934</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2012-12-10T22:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using date macro variable in SQL procedure</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95207#M26935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just always ensure to enclose them in double quotes or else the macro variable won't resolve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 23:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-date-macro-variable-in-SQL-procedure/m-p/95207#M26935</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-12-10T23:59:01Z</dc:date>
    </item>
  </channel>
</rss>

