<?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 a SAS Macro Variable in Teradata SQL Where Clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205190#M267088</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xia,&lt;/P&gt;&lt;P&gt;The code did run but did not return any results. I was already formatting as a date using the following code:&lt;/P&gt;&lt;P&gt;create table work.ToDate as &lt;/P&gt;&lt;P&gt;select datepart(To_Date) as TO_DATE FORMAT=yymmdd10....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is something else causing the issue between SAS and Teradata. Any other suggestions would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jun 2015 14:55:29 GMT</pubDate>
    <dc:creator>madamimadam</dc:creator>
    <dc:date>2015-06-15T14:55:29Z</dc:date>
    <item>
      <title>Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205186#M267084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two variables, each stored in a SAS Macro Variable with the yymmdd10. format. When I hard code the dates using a %let statement (%let Start_Date = '2015-06-09';) the SQL runs fine but when I try to use macro variables in Teradata it gives an error, "Teradata execute: A character string failed conversion to a numeric value." I know the database field "some_date" is a date format and as stated above the hard coded Start_date format works fine. Any suggestions? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;call symput('Start_Date', From_Date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;call symput('End_Date', To_Date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;%let q=%BQUOTE(');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;PROC SQL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;CONNECT TO TERADATA (connection information);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;EXEC(COMMIT) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;EXEC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;INSERT INTO db_name.test_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;SELECT ...some_list...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;FROM db_name.some_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;WHERE some_date between &amp;amp;q&amp;amp;Start_Date&amp;amp;q and &amp;amp;q&amp;amp;End_Date&amp;amp;q&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;EXEC(COMMIT) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;DISCONNECT FROM TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; font-size: 13px; background-color: #fff3db;"&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 17:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205186#M267084</guid>
      <dc:creator>madamimadam</dc:creator>
      <dc:date>2015-06-12T17:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205187#M267085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not Sure if it could work. Code not test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;call symput('Start_Date', &lt;STRONG&gt;cats("'", put(From_Date,yymmdd10.),"'")&amp;nbsp;&amp;nbsp; );&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;call symput('End_Date',&amp;nbsp; &lt;STRONG&gt;&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; background-color: #fff3db;"&gt;cats("'", put(&lt;SPAN style="color: #29303b; font-family: Georgia, 'Times New Roman', sans-serif; background-color: #fff3db;"&gt;To_Date&lt;/SPAN&gt;,yymmdd10.),"'")&amp;nbsp; &lt;/SPAN&gt;);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;PROC SQL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;CONNECT TO TERADATA (connection information);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;EXEC(COMMIT) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;EXEC&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;(&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;INSERT INTO db_name.test_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;SELECT ...some_list...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;FROM db_name.some_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;WHERE some_date between &lt;STRONG&gt;&amp;amp;Start_Date&lt;/STRONG&gt; and &lt;STRONG&gt;&amp;amp;End_Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;EXEC(COMMIT) BY TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;DISCONNECT FROM TERADATA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: Georgia, 'Times New Roman', sans-serif; color: #29303b; background-color: #fff3db;"&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2015 06:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205187#M267085</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-13T06:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205188#M267086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you did not specify a format for your SAS date variable in the DATA _NULL_ code you posted are you sure that SAS is generating the dates in the YYYY-MM-DD format that Teradata expects?&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Also you might add the keyword DATE so that Teradata knows that you mean the quoted string as a date literal.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE datevar BETWEEN DATE '2014-01-01' and DATE '2014-12-31'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can add the single quotes to the macro variable values.&amp;nbsp; Or use a utility macro like %TSLIT() to add the quotes.&amp;nbsp; Or write your own macro.&lt;/P&gt;&lt;P&gt;See this discussion: &lt;A __default_attr="11204" __jive_macro_name="document" class="jive_macro jive_macro_document" href="https://communities.sas.com/" modifiedtitle="true" title="Not All Macro Language Elements Are Supported by the Macro Facility"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2015 08:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205188#M267086</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-13T08:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205189#M267087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Teradata dates are not stored in the way sas dates are stored. &lt;/P&gt;&lt;P&gt;Sas is not supporting sql-2013 and by that missing all interval functions of sql.&lt;/P&gt;&lt;P&gt;The result is is that constant date values may be translated correct onto teradata sql. But that is it, nothing more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2015 19:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205189#M267087</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-06-13T19:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205190#M267088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xia,&lt;/P&gt;&lt;P&gt;The code did run but did not return any results. I was already formatting as a date using the following code:&lt;/P&gt;&lt;P&gt;create table work.ToDate as &lt;/P&gt;&lt;P&gt;select datepart(To_Date) as TO_DATE FORMAT=yymmdd10....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is something else causing the issue between SAS and Teradata. Any other suggestions would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 14:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205190#M267088</guid>
      <dc:creator>madamimadam</dc:creator>
      <dc:date>2015-06-15T14:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205191#M267089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;I output the dates into two tables to check whether the dates are in the correct format before passing to the Teradata code. The dates in the two tables look as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From_Date: 2015-06-14&lt;/P&gt;&lt;P&gt;To_Date: 2015-06-20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did try adding the keyword DATE and got a few errors. Remember the issue does not exist when I do not use a macro variable. When I hard code the string everything works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As well, I used %let q=%BQUOTE('); to add the single quotes to the variable names. Is this the same as what you are suggesting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 15:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205191#M267089</guid>
      <dc:creator>madamimadam</dc:creator>
      <dc:date>2015-06-15T15:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205192#M267090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Japp,&lt;/P&gt;&lt;P&gt;Can you explain a little more what you are saying? I am not sure I understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 15:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205192#M267090</guid>
      <dc:creator>madamimadam</dc:creator>
      <dc:date>2015-06-15T15:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205193#M267091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How the dates look when printed from the data set is not the question. The question is what the macro variables that you want to use to query TD look like.&lt;/P&gt;&lt;P&gt;As with any code generation project it is best to design what code you want to generate first.&amp;nbsp; &lt;/P&gt;&lt;P&gt;So if your dates are Jun14 to Jun20 th of this year then try seeing how many records that would find.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from connection to teradata&lt;/P&gt;&lt;P&gt;(select count(*) as nobs &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;FROM db_name.some_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WHERE some_date between '2015-06-14' and '2015-06-20'&lt;/P&gt;&lt;P&gt;) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that doesn't work then your issue is on the Teradata side.&amp;nbsp; Is "SOME_DATE" really a date variable?&amp;nbsp; Is your default date format different so the '2015-06-14' is not recognized as date literal?&lt;/P&gt;&lt;P&gt;If that works then work on the part that is creating the macro variables to make sure that the value looks like the code above.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('STARTD',cats("'",put(from_date,yymmdd10.),"'");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put STARTD = &amp;amp;STARTD;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use macro quoting such as %BQUOTE to add the single quotes then you might also need to include a call to %UNQUOTE() macro function to remove the macro quoting so that SAS can properly parse the generated code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205193#M267091</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-15T16:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a SAS Macro Variable in Teradata SQL Where Clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205194#M267092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What&amp;nbsp; I am trying to explain is that within TD dates/times are stored as binary numbers types. That type is not known in SAS. Within TD the dates/times are stored by their decimal representation an not as a continous values as SAS does.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The implicit SQL translation can do a lot of the needed translations but cannot do all of them by some of those misalignment.&amp;nbsp; Working with dates times as you are used to with SAS functions will fail. With SQL2013 there are a lot of Datetime functions in the DBMS system. TD is supporting that. SAS is far behind with SQL-99.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The datepart function and assigning a format in sas is effectively killing the TD advantage. In those cases you are better with e plicit SQL as it will leave the work in TD. You can decide for views in TD avoiding additional data copies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia posted an attempt to explicit pass through. The sql should be TD sql not SAS sql. There are many differences in those.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2015 05:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-SAS-Macro-Variable-in-Teradata-SQL-Where-Clause/m-p/205194#M267092</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-06-17T05:56:18Z</dc:date>
    </item>
  </channel>
</rss>

