<?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: Proc sql with date condition in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59203#M16684</link>
    <description>The macro variable will resolve to a string - Proc SQL will see this string.&lt;BR /&gt;
Therefore pass exactly the needed string to the macro variable as if you would write it directly in the SQL statement.&lt;BR /&gt;
&lt;BR /&gt;
%let mydate='2005-05-31';&lt;BR /&gt;
Proc sql,&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
. &lt;BR /&gt;
where file_date=&amp;amp;mydate;</description>
    <pubDate>Sun, 02 Nov 2008 04:18:57 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2008-11-02T04:18:57Z</dc:date>
    <item>
      <title>Proc sql with date condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59202#M16683</link>
      <description>I usually pull data from data warehouse with the date condition like this....&lt;BR /&gt;
Proc sql,&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
. &lt;BR /&gt;
where file_date='2005-05-31';&lt;BR /&gt;
&lt;BR /&gt;
Now I'm trying to repeated calling the sql with different date by using a macro and passing the file_date, what format of the date should I use? Should I create a character string like '2005-06-30' or a SAS date format like '30Jun05'd?</description>
      <pubDate>Sat, 01 Nov 2008 22:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59202#M16683</guid>
      <dc:creator>JJJJ</dc:creator>
      <dc:date>2008-11-01T22:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql with date condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59203#M16684</link>
      <description>The macro variable will resolve to a string - Proc SQL will see this string.&lt;BR /&gt;
Therefore pass exactly the needed string to the macro variable as if you would write it directly in the SQL statement.&lt;BR /&gt;
&lt;BR /&gt;
%let mydate='2005-05-31';&lt;BR /&gt;
Proc sql,&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
. &lt;BR /&gt;
where file_date=&amp;amp;mydate;</description>
      <pubDate>Sun, 02 Nov 2008 04:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59203#M16684</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-11-02T04:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql with date condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59204#M16685</link>
      <description>Why burden the caller with having to code quote marks?  Suggest you remove them from the macro variable assignment and code them in the WHERE.  Also, the SAS data variable's format will determine whether the WHERE statement must specify a character-string or a SAS date literal.  Lastly, the INPUT function can also be used in the WHERE, rather than forcing the caller to use SAS date-literal format of ddmmmyyyy.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 02 Nov 2008 15:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59204#M16685</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-11-02T15:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql with date condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59205#M16686</link>
      <description>Just one note. Using functions in WHERE statement is &lt;I&gt;not&lt;/I&gt; recommended due to performance issues. By using functions there will be no WHERE optimization (=no index usage). Starting from 9.2, queries using functions on constants (i.e. macro variables) &lt;I&gt;can&lt;/I&gt; be optimized.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Mon, 03 Nov 2008 08:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59205#M16686</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-11-03T08:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql with date condition</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59206#M16687</link>
      <description>&amp;gt; Why burden the caller with having to code quote marks?&lt;BR /&gt;
&lt;BR /&gt;
Because according to the example it could be pass-through SQL - and Oracle for example doesn't like double quotes.&lt;BR /&gt;
On the other hand the example shows very clear that the value has to be passed as character string.</description>
      <pubDate>Mon, 03 Nov 2008 08:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-with-date-condition/m-p/59206#M16687</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-11-03T08:16:37Z</dc:date>
    </item>
  </channel>
</rss>

