<?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: Pass Date macro Variable into a PROC SQL Where statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358160#M84137</link>
    <description>&lt;P&gt;Out of curiousity: did my step &lt;U&gt;as written&lt;/U&gt; do the trick, or did you have to adapt it? Mind that I have absolutely no experience with SQL Server passthrough, and &lt;U&gt;very&lt;/U&gt; little with passthrough to UDB/DB2. Our communication with the database is done solely by flatfiles.&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 06:54:22 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-05-12T06:54:22Z</dc:date>
    <item>
      <title>Pass Date macro Variable into a PROC SQL Where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358152#M84134</link>
      <description>&lt;P&gt;I am trying to write a PROC SQL statement which is extracting data from SQL Server based on some date criteria.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let ExamStartDate = 01APR2017;&lt;BR /&gt;%let ExamEndDate = 01MAY2017;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symputx('sdate',put("&amp;amp;ExamStartDate."d,yymmdd10.));&lt;BR /&gt;call symputx('edate',put("&amp;amp;ExamEndDate."d,yymmdd10.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to odbc (dsn='aa' user=user pw=pw);&lt;BR /&gt;create table temp1 as select * from connection to odbc&lt;BR /&gt;(&lt;BR /&gt;SELECT cnd.firstName,&amp;nbsp;cnd.middleName, cnd.lastName, cd.calendarDate as date&lt;BR /&gt;FROM&amp;nbsp;candidate cnd&amp;nbsp;inner join CalendarDate cd with (NOLOCK) on cd.calendarDateId=cnd.eventDateId&lt;BR /&gt;and cd.calendarDate &amp;gt;= convert(datetime,&amp;amp;sdate.)&lt;BR /&gt;);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code, it gives me all records and does not filter out the data. Can anyone suggest what am I doing wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358152#M84134</guid>
      <dc:creator>deepika2</dc:creator>
      <dc:date>2017-05-12T06:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Date macro Variable into a PROC SQL Where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358157#M84135</link>
      <description>&lt;P&gt;Use the &lt;A href="http://support.sas.com/documentation/cdl/en/engfedsrv/70118/HTML/default/viewer.htm#n167fxh8cc9h2an198cln7b46vb9.htm" target="_blank"&gt;SASTRACE=&lt;/A&gt; system option to get more information back from the data source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be that the SQL Server expects dates in a format like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx('sdate','"'!!put("&amp;amp;ExamStartDate."d,yymmddd10.)!!'"');
call symputx('edate','"'!!put("&amp;amp;ExamEndDate."d,yymmddd10.)!!'"');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so the string that is handed over will be "2017-04-01" (including the quotes). And you might need to supply timestamps instead of dates, as you use the type datetime in the convert, if I interpret that correctly.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358157#M84135</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-12T06:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Date macro Variable into a PROC SQL Where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358158#M84136</link>
      <description>&lt;P&gt;Thanks for the quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;It actually worked.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358158#M84136</guid>
      <dc:creator>deepika2</dc:creator>
      <dc:date>2017-05-12T06:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Date macro Variable into a PROC SQL Where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358160#M84137</link>
      <description>&lt;P&gt;Out of curiousity: did my step &lt;U&gt;as written&lt;/U&gt; do the trick, or did you have to adapt it? Mind that I have absolutely no experience with SQL Server passthrough, and &lt;U&gt;very&lt;/U&gt; little with passthrough to UDB/DB2. Our communication with the database is done solely by flatfiles.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Date-macro-Variable-into-a-PROC-SQL-Where-statement/m-p/358160#M84137</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-12T06:54:22Z</dc:date>
    </item>
  </channel>
</rss>

