<?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: Help needed for date formatting in macro! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51401#M10756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've never worked with db2 but I don't think it has a date9. format.&amp;nbsp; Are you sure it isn't one of the ones shown at: &lt;A href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.admin.doc%2Fdoc%2Fr0008474.htm"&gt;http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.admin.doc%2Fdoc%2Fr0008474.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Feb 2012 14:33:37 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-02-10T14:33:37Z</dc:date>
    <item>
      <title>Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51391#M10746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there, I'm having some difficulty with date formatting in my macro. I'm trying to equate a mmddyy10. format with a sas integer date format. I'm trying to translate the dates in sas format into mmddyy10. format but it's giving me several errors.&amp;nbsp; My code &amp;amp; log is below. &lt;SPAN style="font-size: 12pt;"&gt;Any help is much appreciated! Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; experience_dt= "05jan2012"d;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; oldest_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,&amp;amp;experience_dt,-30,begin));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; newest_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,&amp;amp;experience_dt,-2,end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; oldest_yr = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(year(&amp;amp;oldest_dt));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; newest_yr = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(year(&amp;amp;newest_dt));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;options&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;obs&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; x();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; i = &amp;amp;oldest_yr &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &amp;amp;newest_yr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; newyear = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,"01jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; old_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(inputn(&amp;amp;oldest_dt,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; new_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(inputn(&amp;amp;newest_dt,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; new_yr = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(inputn(&amp;amp;newyear,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;create table steff.NB_ATT_plcytrm&amp;amp;i as select distinct * from connection to db2 (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;select *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;from edw.table_a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;where effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(max(&amp;amp;old_dt,&amp;amp;new_yr)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;and effective_dt &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(min(&amp;amp;new_dt,&amp;amp;new_yr))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;quit;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;%&lt;STRONG&gt;&lt;EM&gt;x&lt;/EM&gt;&lt;/STRONG&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, I'm trying to use the inputn function to convert the date formatting but it's giving me these errors in the log:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable OLDEST_YR resolves to 2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEWEST_YR resolves to 2011&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable OLDEST_DT resolves to 18079&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal;"&gt;WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to a missing value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEWEST_DT resolves to 18961&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal;"&gt;WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to a missing value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEWYEAR resolves to 17898&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal;"&gt;WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to a missing value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable USER resolves to u51pso&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable BQPPASS resolves to {sas001}cmF3cjU2NTY=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable OLD_DT resolves to .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEW_YR resolves to .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEW_DT resolves to .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable NEW_YR resolves to .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0104N&amp;nbsp; An unexpected token "." was found following "plcy_trm_efctv_dt &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;=".&amp;nbsp; Expected tokens may include:&amp;nbsp; "&amp;lt;update_source_no_row_query&amp;gt;".&amp;nbsp; SQLSTATE=42601&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #000080; font-size: 12pt;"&gt;&lt;SPAN style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #008080; font-size: 12pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #008080; font-size: 12pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #008080; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #000080; font-size: 12pt;"&gt;&lt;SPAN style="color: #000080; font-size: 12pt; font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 22:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51391#M10746</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-09T22:59:56Z</dc:date>
    </item>
    <item>
      <title>Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51392#M10747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; old_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(inputn(&amp;amp;oldest_dt,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable OLDEST_DT resolves to 18079&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal;"&gt;WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have generated in OLDEST_DT the number of days since 1/1/1960.&amp;nbsp; If you want to make that look like a date then you can use PUTN function.&amp;nbsp; You probably do not even need convert it as you are just going to use the value 18079 later on in your SQL query.&lt;/P&gt;&lt;P&gt;You could also use a format for your SYSFUNC call back when you created OLDEST_DT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let oldest_dt = %sysfunc(intnx(month,&amp;amp;experience_dt,-30,begin),date9.);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;where effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;max("&amp;amp;oldest_dt"d,"&amp;amp;new_yr"d)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might also look into doing these calculations in a data step instead of macro code. Much easier to code and debug.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 23:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51392#M10747</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-09T23:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51393#M10748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think your code is the same as mine. the condition in proc sql will never be true.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id effective_dt mmddyy10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 01/01/2009&lt;/P&gt;&lt;P&gt;2 11/30/2009&lt;/P&gt;&lt;P&gt;3 01/01/2010 &lt;/P&gt;&lt;P&gt;4 11/30/2010 &lt;/P&gt;&lt;P&gt;5 01/01/2011 &lt;/P&gt;&lt;P&gt;6 11/30/2011&lt;/P&gt;&lt;P&gt;7 &lt;/P&gt;&lt;P&gt;; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let experience_dt= "05jan2012"d;&lt;/P&gt;&lt;P&gt;%let oldest_dt = %sysfunc(intnx(month,&amp;amp;experience_dt,-30,begin));&lt;/P&gt;&lt;P&gt;%let newest_dt = %sysfunc(intnx(month,&amp;amp;experience_dt,-2,end));&lt;/P&gt;&lt;P&gt;%let oldest_yr = %sysfunc(year(&amp;amp;oldest_dt));&lt;/P&gt;&lt;P&gt;%let newest_yr = %sysfunc(year(&amp;amp;newest_dt));&lt;/P&gt;&lt;P&gt;%put &amp;amp;experience_dt &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;oldest_dt &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;newest_dt &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;oldest_yr &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;newest_yr;&lt;/P&gt;&lt;P&gt;%macro x();&lt;/P&gt;&lt;P&gt;%do i = &amp;amp;oldest_yr %to &amp;amp;newest_yr;&lt;/P&gt;&lt;P&gt;%let newyear = %sysfunc(mdy(1,1,&amp;amp;i));&lt;/P&gt;&lt;P&gt;%let old_dt = &amp;amp;oldest_dt;&lt;/P&gt;&lt;P&gt;%let new_dt = &amp;amp;newest_dt;&lt;/P&gt;&lt;P&gt;%let new_yr = &amp;amp;newyear;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want&amp;amp;i as select *&lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;where effective_dt &amp;gt;= %sysfunc(max(&amp;amp;old_dt,&amp;amp;new_yr))&lt;/P&gt;&lt;P&gt;and effective_dt &amp;lt; %sysfunc(min(&amp;amp;new_dt,&amp;amp;new_yr))&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%x();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 01:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51393#M10748</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-02-10T01:41:21Z</dc:date>
    </item>
    <item>
      <title>Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51394#M10749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thanks so much, Tom &amp;amp; Linlin. I actually tried Tom's suggestions first of putting a format in my %SYSFUNC and it worked! Now, it's just giving me one more small problem.&amp;nbsp; Now the min and max functions are not understanding how to compare the dates because they're not numbers. Here's my code again and the corresponding log.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; i = &amp;amp;oldest_yr &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &amp;amp;newest_yr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; newyear = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,"01jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; old_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,&amp;amp;oldest_dt,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; new_dt = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,&amp;amp;newest_dt,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; new_yr = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(intnx(month,&amp;amp;newyear,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;create table steff.NB_ATT_plcytrm&amp;amp;i as select distinct * from connection to db2 (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;select *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;from abc.table_a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;where effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(max(&amp;amp;old_dt,&amp;amp;new_yr)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;AND BSNS_BSS_CD = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'V'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;and crprtn_yr_cn=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;and effective_dt &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;(min(&amp;amp;new_dt,&amp;amp;new_yr))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;quit;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;ERROR: Argument 1 to function MIN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;ERROR: Argument 2 to function MIN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.&amp;nbsp; Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0104N&amp;nbsp; An unexpected token "." was found following "effective_dt &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;=".&amp;nbsp; Expected tokens may include:&amp;nbsp; "&amp;lt;update_source_no_row_query&amp;gt;".&amp;nbsp; SQLSTATE=42601&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: red;"&gt;THANKS!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51394#M10749</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T13:35:51Z</dc:date>
    </item>
    <item>
      <title>Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51395#M10750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you try it using the syntax that Tom had suggested?, namely:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;where effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;max("&amp;amp;oldest_dt"d,"&amp;amp;new_yr"d)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51395#M10750</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-10T13:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51396#M10751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; When I do that, it gives me this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable OLD_DT resolves to 01JUL2009&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable NEW_YR resolves to 01JAN2010&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable NEW_DT resolves to 30NOV2011&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable NEW_YR resolves to 01JAN2010&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0401N The data types of the operands for the operation "&amp;gt;=" are not &lt;/P&gt;&lt;P&gt;compatible or comparable. SQLSTATE=42818 &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51396#M10751</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T13:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51397#M10752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; So it looks like the dates are finally getting translated into the format that I want, because that's the same format that effective_dt is in. BUT, now min/max doesn't work on that format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51397#M10752</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T13:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51398#M10753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is effective_dt a timestamp or datetime value rather than a date?&amp;nbsp; If so, you have to compare apples with apples.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51398#M10753</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-10T13:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51399#M10754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like your WHERE clause is being pushed into a database.&amp;nbsp; Where does the libref ABC point?&amp;nbsp; You probably might need to format the dates in the syntax that your database wants.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 13:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51399#M10754</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-10T13:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51400#M10755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; The database format is a date with date9 format...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 14:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51400#M10755</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T14:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51401#M10756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've never worked with db2 but I don't think it has a date9. format.&amp;nbsp; Are you sure it isn't one of the ones shown at: &lt;A href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.admin.doc%2Fdoc%2Fr0008474.htm"&gt;http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.admin.doc%2Fdoc%2Fr0008474.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 14:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51401#M10756</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-10T14:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51402#M10757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you want to try changing your select statement&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; abc.table_a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(max(&amp;amp;old_dt,&amp;amp;new_yr)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; BSNS_BSS_CD = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'V'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; crprtn_yr_cn=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; effective_dt &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(min(&amp;amp;new_dt,&amp;amp;new_yr))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;to&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; abc.table_a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; effective_dt &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(putn(&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(max(“&amp;amp;old_dt”d,”&amp;amp;new_yr”d)),&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal; font-size: 12pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; BSNS_BSS_CD = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'V'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; crprtn_yr_cn=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; effective_dt &amp;lt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(putn(&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(min(“&amp;amp;new_dt”d,”&amp;amp;new_yr”d)),&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal; font-size: 12pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 14:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51402#M10757</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-02-10T14:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51403#M10758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; When I do that, it goes back to the min/max functions not recognizing the dates are not numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt; font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: Argument 1 to function MIN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;/P&gt;&lt;P&gt;ERROR: Argument 2 to function MIN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;/P&gt;&lt;P&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC &lt;/P&gt;&lt;P&gt;or %QSYSFUNC function reference is terminated.&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0103N The numeric literal "01JUL2009" is not valid. SQLSTATE=42604&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 14:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51403#M10758</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T14:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51404#M10759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; It should work. this is how I tested:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; i=2009;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v1 = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(intnx(month,"01jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v2 = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(intnx(month,&amp;amp;v1,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v3 = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(intnx(month,"09jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v4 = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(intnx(month,&amp;amp;v3,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v5=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(max("&amp;amp;v2"d,"&amp;amp;v4"d));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v6=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(min("&amp;amp;v2"d,"&amp;amp;v4"d));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v7=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(putn(&amp;amp;v5,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v8=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;(putn(&amp;amp;v6,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: white;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &amp;amp;v1 &amp;amp;v2 &amp;amp;v3 &amp;amp;v4 &amp;amp;v5 &amp;amp;v6 &amp;amp;v7 &amp;amp;v8;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: white;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: white;"&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;From log file:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;165&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;166&amp;nbsp; %let i=2009;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;167&amp;nbsp; %let v1 = %sysfunc(intnx(month,"01jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;168&amp;nbsp; %let v2 = %sysfunc(intnx(month,&amp;amp;v1,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;169&amp;nbsp; %let v3 = %sysfunc(intnx(month,"09jan&amp;amp;i"d,0,sameday));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;170&amp;nbsp; %let v4 = %sysfunc(intnx(month,&amp;amp;v3,0,sameday),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;171&amp;nbsp; %let v5=%sysfunc(max("&amp;amp;v2"d,"&amp;amp;v4"d));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;172&amp;nbsp; %let v6=%sysfunc(min("&amp;amp;v2"d,"&amp;amp;v4"d));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;173&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;174&amp;nbsp; %let v7=%sysfunc(putn(&amp;amp;v5,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;175&amp;nbsp; %let v8=%sysfunc(putn(&amp;amp;v6,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;176&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;177&amp;nbsp; %put &amp;amp;v1 &amp;amp;v2 &amp;amp;v3 &amp;amp;v4 &amp;amp;v5 &amp;amp;v6 &amp;amp;v7 &amp;amp;v8;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt;17898 01JAN2009 17906 09JAN2009 17906 17898 09JAN2009 01JAN2009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 15:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51404#M10759</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-02-10T15:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51405#M10760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Looks like the condition in SQL might call for a NOT BETWEEN:&lt;/P&gt;&lt;P&gt;sql-expression &amp;lt;NOT&amp;gt; &lt;SPAN class="strong"&gt;BETWEEN&lt;/SPAN&gt; sql-expression &lt;SPAN class="strong"&gt;AND&lt;/SPAN&gt; sql-expression &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 16:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51405#M10760</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-02-10T16:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51406#M10761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Test just writing the SQL query without any macro code to see what format the command needs to be to work.&lt;/P&gt;&lt;P&gt;If your source data is in a SAS dataset then it will recognize syntax like &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; effective_dt &amp;gt;= "01JAN2009"d &lt;/P&gt;&lt;P&gt;without syntax errors.&amp;nbsp; Now if EFFECTIVE_DT is actually a DateTime variable instead of a Date variable then all records will have values greater than any resonable date value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If instead your source data is in an Oracle, DB2 or other external database then it might give you a syntax error because SAS is trying to push the WHERE condition into the database and that database uses a different format for date literals.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 16:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51406#M10761</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-10T16:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51407#M10762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone, but unfortunately this is still giving me issues. It's just not understanding date formats in this macro, no matter which way i try to express them. when they're in date9, it gives me this error. is anyone familiar with the 'numeric literal'?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt; font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0103N The numeric literal "01JUL2009" is not valid. SQLSTATE=42604 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 18:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51407#M10762</guid>
      <dc:creator>stefflovessas</dc:creator>
      <dc:date>2012-02-10T18:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51408#M10763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at this SAS publication. &lt;A href="http://support.sas.com/techsup/technote/ts566a.pdf"&gt;http://support.sas.com/techsup/technote/ts566a.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It looks like DB2 wants datetime constants in the format 'YYYYMMDDHHMMSS'.&amp;nbsp; It probably also wants the single quote characters rather than double quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 18:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51408#M10763</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-10T18:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51409#M10764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have one and/or two problems. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The date format ddmmmyyyy may not be interpreted as a valid date string in db2. You should try yymmdd10. which is recognized by many dbms'.&lt;/P&gt;&lt;P&gt;2. In SQL pass-through, you need to make sure that the sql statements formed by any resolved macros are in the form that is recognized by the dbms. For example, I often pass date values in macros to a Teradata database. I first format the dates as yymmdd10.. Then I have to enclose the date value in single quotes. So most Teradata sql statements involving dates are written like this in my SAS code: where start_date = %str(%')&amp;amp;dateval%str(%'). When the SAS code runs, the masked single quotes allow the macro dateval to resolve, but the resulting date parameter will have single quotes that get passed to the Teradata sql processor which is expecting single quotes around data strings. I haven't worked with db2 in many years, so I cannot recall if date strings require singel quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 18:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51409#M10764</guid>
      <dc:creator>FloydNevseta</dc:creator>
      <dc:date>2012-02-10T18:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help needed for date formatting in macro!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51410#M10765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest you send us some plain PROC SQL code which you've tested. Eg. something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create view work.NB_ATT_plcytrmTEST as &lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct * from connection to db2 (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from edw.table_a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where effective_dt GE &amp;lt;hard coded date value in DB2 syntax&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and effective_dt LT &amp;lt;hard coded data value DB2 syntax&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then you tell us exactly what you want to achieve - eg. create yearly SAS tables based on a start date and a number of years (you see I don't fully understand what you're after based on the code you've posted).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the initial macro code you've posted, I feel there could be an easier approach (eg: one query to the data base creating a view and then a SAS data step executing this view and splitting up the data into multiple SAS tables).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Feb 2012 01:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-needed-for-date-formatting-in-macro/m-p/51410#M10765</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-02-11T01:49:39Z</dc:date>
    </item>
  </channel>
</rss>

