<?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: Getting Error when a Datepart function is applied on a Teradata variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21920#M3530</link>
    <description>I am getting Teradata Prepare error.</description>
    <pubDate>Thu, 03 Mar 2011 17:29:57 GMT</pubDate>
    <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
    <dc:date>2011-03-03T17:29:57Z</dc:date>
    <item>
      <title>Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21918#M3528</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Using SQL Pass Through Facility, I connected to Teradata and was planning to create a SAS dataset. In the WHERE clause of PROC SQL, i used datepart function to pull the date from Teradata datetime value and to compare with a macro variable.    &lt;BR /&gt;
&lt;BR /&gt;
I am getting an error. Please help.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 03 Mar 2011 16:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21918#M3528</guid>
      <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
      <dc:date>2011-03-03T16:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21919#M3529</link>
      <description>What's the error? &lt;BR /&gt;
&lt;BR /&gt;
Here's a few things you can look into:&lt;BR /&gt;
1) Does SQL pass through the function your using? &lt;BR /&gt;
See&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/23/194.html" target="_blank"&gt;http://support.sas.com/kb/23/194.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
2) Is the macro variable resolving properly?</description>
      <pubDate>Thu, 03 Mar 2011 17:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21919#M3529</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-03-03T17:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21920#M3530</link>
      <description>I am getting Teradata Prepare error.</description>
      <pubDate>Thu, 03 Mar 2011 17:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21920#M3530</guid>
      <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
      <dc:date>2011-03-03T17:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21921#M3531</link>
      <description>I'm assuming the query works without the where clause or when the date you're comparing to is a full date (ie not using datepart)? &lt;BR /&gt;
&lt;BR /&gt;
It would help if you posted the log with the code and error message,  if possible, XXXX'ing out any confidential info.</description>
      <pubDate>Thu, 03 Mar 2011 18:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21921#M3531</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-03-03T18:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21922#M3532</link>
      <description>Here is the code and error log below,&lt;BR /&gt;
&lt;BR /&gt;
91   rsubmit;&lt;BR /&gt;
NOTE: Remote submit to DV commencing.&lt;BR /&gt;
292  %let START_YYYYMMDD=20100801;&lt;BR /&gt;
293  proc sql noprint;&lt;BR /&gt;
294  connect to teradata as tera (tdpid=PTIA1EDW user="XXXXX" password=XXXXX);&lt;BR /&gt;
295     create table abc as&lt;BR /&gt;
296       select * from connection to tera&lt;BR /&gt;
297     ( select row_id, &lt;BR /&gt;
298              c_num,&lt;BR /&gt;
299              c_status,&lt;BR /&gt;
300              c_type,&lt;BR /&gt;
301              input(put( datepart(start_dt), yymmddn8.), 8.) as max_start_dt&lt;BR /&gt;
302       from w_source_d&lt;BR /&gt;
303       where&lt;BR /&gt;
304          upper(c_type)='IND' and&lt;BR /&gt;
305          camp_status in ('L','C') and&lt;BR /&gt;
306         datepart(start_dt) &amp;gt;= input( "&amp;amp;START_YYYYMMDD", yymmdd8.)&lt;BR /&gt;
307     );&lt;BR /&gt;
ERROR: Teradata prepare: Syntax error: expected something between ',' and the 'input' keyword. SQL statement was: select row_id, c_num, c_status, c_type, &lt;BR /&gt;
input(put( datepart(start_dt), yymmddn8.), 8.) as max_start_dt from w_source_d &lt;BR /&gt;
where upper(c_type)='IND' and camp_status in ('L','C') and &lt;BR /&gt;
datepart(start_dt) &amp;gt;=input( "&amp;amp;START_YYYYMMDD", yymmdd8.).&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 03 Mar 2011 19:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21922#M3532</guid>
      <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
      <dc:date>2011-03-03T19:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21923#M3533</link>
      <description>you have a format in there, yymmddn8.   Is that a valid sas format or a custom format that's been defined?</description>
      <pubDate>Thu, 03 Mar 2011 19:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21923#M3533</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-03-03T19:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21924#M3534</link>
      <description>yymmddn8. is a valid sas format. &lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
lm</description>
      <pubDate>Thu, 03 Mar 2011 19:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21924#M3534</guid>
      <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
      <dc:date>2011-03-03T19:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21925#M3535</link>
      <description>I'm still not sure that Teradata knows how to interpret the datepart function is pass-through code. &lt;BR /&gt;
See valid functions here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/teradata.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/teradata.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
However, I am unfamiliar with that specific db so possibly post your question on SAS-L for more responses. &lt;BR /&gt;
&lt;BR /&gt;
Cheers, &lt;BR /&gt;
Reeza</description>
      <pubDate>Thu, 03 Mar 2011 19:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21925#M3535</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-03-03T19:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21926#M3536</link>
      <description>try changing line 301 to drop the input and put and change where the format is assinged&lt;BR /&gt;
&lt;BR /&gt;
datepart(start_dt) as max_start_dt format=yymmdd8.&lt;BR /&gt;
&lt;BR /&gt;
then you should be able to change line 306 to &lt;BR /&gt;
&lt;BR /&gt;
max_start_dt &amp;gt;= "START_YYYYMMDD"</description>
      <pubDate>Thu, 03 Mar 2011 20:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21926#M3536</guid>
      <dc:creator>garybald</dc:creator>
      <dc:date>2011-03-03T20:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21927#M3537</link>
      <description>Instead of using explicit SQL you could instead do it implicitly.  Below is an example quickly rewriting your proc sql.&lt;BR /&gt;
&lt;BR /&gt;
libname trlib teradata user=fakeuser password=fakepass;  &lt;BR /&gt;
&lt;BR /&gt;
%let START_YYYYMMDD=20100801;&lt;BR /&gt;
&lt;BR /&gt;
data abc;&lt;BR /&gt;
 set trlib.w_source_d(&lt;BR /&gt;
   keep=row_id c_num c_status c_type start_dt camp_status&lt;BR /&gt;
   where=(upper(c_type)='IND' and camp_status in ('L','C') and datepart(start_dt) &amp;gt;= "&amp;amp;START_YYYYMMDD"d));&lt;BR /&gt;
 max_start_dt=datepart(start_dt);&lt;BR /&gt;
 drop camp_status start_dt;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
In the above SAS should process the where clause in-database if the datepart function is compatible, otherwise it will process it downstream.  This method is usually slower.  There is plenty of documentation around on that if you look for it.</description>
      <pubDate>Thu, 03 Mar 2011 21:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21927#M3537</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-03-03T21:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21928#M3538</link>
      <description>solve your problem with an alternative approach.&lt;BR /&gt;
Instead of making Teradata convert its date time value into a date so that you can compare with your date macro variable, just convert the use of your date macro variable to look like a datetime - much simpler for all concerned!&lt;BR /&gt;
&lt;BR /&gt;
using implicit pass-thru allows you to keep it streamlined, and use sas datetime constants ...&lt;BR /&gt;
&lt;BR /&gt;
 %let START_YYYYMMDD=20100801;&lt;BR /&gt;
 %let start_date = 01AUG2010 ; * simpler for SAS syntax in date constant form;&lt;BR /&gt;
 proc sql noprint;&lt;BR /&gt;
 libname tera teradata tpdid=PTIA1EDW user="XXXXX" password=XXXXX ;&lt;BR /&gt;
* not entirely sure of this syntax ;&lt;BR /&gt;
 create table abc as&lt;BR /&gt;
select row_id, &lt;BR /&gt;
 c_num,&lt;BR /&gt;
 c_status,&lt;BR /&gt;
 c_type,&lt;BR /&gt;
 start_dt as max_start_dtime&lt;BR /&gt;
 from tera.w_source_d&lt;BR /&gt;
 where&lt;BR /&gt;
 upcase(c_type)='IND' and&lt;BR /&gt;
 camp_status in ('L','C') and&lt;BR /&gt;
 start_dt GE "&amp;amp;START_date:0:0:0"dt&lt;BR /&gt;
 ;&lt;BR /&gt;
variable MAX_START_dTime will be extracted as a datetime value, but that can be converted in your next step, there should be no need to trouble Teradata with a SAS function like DATEPART()&lt;BR /&gt;
 &lt;BR /&gt;
for better examples, see Coders' Corner paper 105-2011 "Explicit SQL Pass-Through: Is It Still Useful?" by Frank Capobianco of the Teradata Corporation.&lt;BR /&gt;
 &lt;BR /&gt;
better still, next month, come, listen to Frank and ask questions&lt;BR /&gt;
SAS Global Forum 2011, Las Vegas &lt;BR /&gt;
Cesears Palace,  6-April-2011 14:00 room  Roman II&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Sat, 05 Mar 2011 10:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21928#M3538</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-05T10:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21929#M3539</link>
      <description>Thank you for reply Peter ! But i could not found the document, Could you please post me the link once again.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Lm</description>
      <pubDate>Mon, 07 Mar 2011 20:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21929#M3539</guid>
      <dc:creator>DatepartfunctiononaTeradatavariable</dc:creator>
      <dc:date>2011-03-07T20:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error when a Datepart function is applied on a Teradata variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21930#M3540</link>
      <description>start here &lt;BR /&gt;
&lt;A href="http://support.sas.com/events/sasglobalforum/2011/" target="_blank"&gt;http://support.sas.com/events/sasglobalforum/2011/&lt;/A&gt;</description>
      <pubDate>Mon, 07 Mar 2011 22:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Error-when-a-Datepart-function-is-applied-on-a-Teradata/m-p/21930#M3540</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-07T22:23:39Z</dc:date>
    </item>
  </channel>
</rss>

