<?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: how to modify oracle code in proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24509#M5547</link>
    <description>If your code is a direct extract from between PROC SQL and your QUIT; lines, then you'll need to run this code in Pass-Through mode I think.&lt;BR /&gt;
&lt;BR /&gt;
Functions like trunc() and partition by aren't SAS functions so your code flags these as an error.&lt;BR /&gt;
&lt;BR /&gt;
Try something from &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm&lt;/A&gt; .</description>
    <pubDate>Wed, 09 Mar 2011 09:33:05 GMT</pubDate>
    <dc:creator>DF</dc:creator>
    <dc:date>2011-03-09T09:33:05Z</dc:date>
    <item>
      <title>how to modify oracle code in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24506#M5544</link>
      <description>CREATE TABLE FMEA_BASE AS&lt;BR /&gt;
select org, location,description,anum,pcode, FCODE,&lt;BR /&gt;
trunc(to_char(faildate- lag(faildate,1) over (partition by assetnum order by faildate)),2) as TBF_Days,&lt;BR /&gt;
(trunc(to_char(faildate- lag(faildate,1) over (partition by assetnum order by faildate)),2))*24 as TBF_Hrs,&lt;BR /&gt;
(trunc(actfinish-actstart,2))*24 as TTR_Hrs&lt;BR /&gt;
&lt;BR /&gt;
from work&lt;BR /&gt;
where  location is not null and anum is not null&lt;BR /&gt;
&lt;BR /&gt;
order by assetnum;&lt;BR /&gt;
&lt;BR /&gt;
========================================================&lt;BR /&gt;
This code works f9 in Oracle DB ,but i when i m trying to run this code in sas but i am getting  errors&lt;BR /&gt;
OVER,PARTITION BY keyword are not identifying by SAS&lt;BR /&gt;
&lt;BR /&gt;
please guide me to convert this oracle code into SAS using proc sql;</description>
      <pubDate>Tue, 08 Mar 2011 14:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24506#M5544</guid>
      <dc:creator>sss</dc:creator>
      <dc:date>2011-03-08T14:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to modify oracle code in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24507#M5545</link>
      <description>You need to show more of your code and log.  How are you connecting to the Oracle database.  LIBNAME, pass thru using Oracle, or pass thru using ODBC.  Each has different characteristics.  If you are using LIBNAME, then you need to use SAS SQL syntax.  Pass thru to oracle should give you the most transparency though, even then, there are options to control any optimization that SAS might attempt.&lt;BR /&gt;
&lt;BR /&gt;
Check the SAS/Access to Relational Databases and SAS/Access Companion for Oracle.</description>
      <pubDate>Tue, 08 Mar 2011 15:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24507#M5545</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-03-08T15:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to modify oracle code in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24508#M5546</link>
      <description>Hey&lt;BR /&gt;
I am connecting through ODBC to oracle DB&lt;BR /&gt;
&lt;BR /&gt;
This is the error msg&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Due to the PRESERVE_TAB_NAMES=NO libname option setting, 954&lt;BR /&gt;
      table(s) have not been displayed/returned.&lt;BR /&gt;
1    proc sql;&lt;BR /&gt;
2    CREATE TABLE FMEA_BASE AS&lt;BR /&gt;
3    select orgid,siteid , location,description,assetnum,problemcode,&lt;BR /&gt;
3  ! FAILURECODE,&lt;BR /&gt;
4    to_char(faildate,'MM/DD/YYYY') AS FAILDATE,&lt;BR /&gt;
5    to_char(actstart,'MM/DD/YYYY') AS ACTSTART,&lt;BR /&gt;
6    to_char(ACTFINISH,'MM/DD/YYYY') AS ACTFINISH,&lt;BR /&gt;
7    trunc(to_char(faildate- lag(faildate,1) over (partition by assetnum&lt;BR /&gt;
                                             ----            --&lt;BR /&gt;
                                             22              76&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;,&lt;BR /&gt;
              *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND,&lt;BR /&gt;
              BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET,&lt;BR /&gt;
              LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
7  ! trunc(to_char(faildate- lag(faildate,1) over (partition by assetnum&lt;BR /&gt;
                                                             --&lt;BR /&gt;
                                                             22&lt;BR /&gt;
7  !  order by faildate)),2) as TBF_Days,&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;,&lt;BR /&gt;
              (, ), *, **, +, ',', -, '.', /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?,&lt;BR /&gt;
              AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN,&lt;BR /&gt;
              IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^,&lt;BR /&gt;
              ^=, |, ||, ~, ~=.&lt;BR /&gt;
&lt;BR /&gt;
8    (trunc(to_char(faildate- lag(faildate,1) over (partition by&lt;BR /&gt;
8  ! assetnum order by faildate)),2))*24 as TBF_Hrs,&lt;BR /&gt;
9    (trunc(actfinish-actstart,2))*24 as&lt;BR /&gt;
9  ! TTR_Hrs,(actmatcost+actlabcost+acttoolcost) as FAILURECOST&lt;BR /&gt;
10   from tva.workorder&lt;BR /&gt;
11   where classstructureid is not null&lt;BR /&gt;
12   and location is not null&lt;BR /&gt;
13   and assetnum is not null&lt;BR /&gt;
14   and faildate is not null&lt;BR /&gt;
15   and actstart is not null&lt;BR /&gt;
16   and actfinish is not null&lt;BR /&gt;
17   order by assetnum;&lt;BR /&gt;
18   quit;&lt;BR /&gt;
&lt;BR /&gt;
I have read a document where i came to know that lag function cannot me used in proc sql;</description>
      <pubDate>Tue, 08 Mar 2011 15:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24508#M5546</guid>
      <dc:creator>sss</dc:creator>
      <dc:date>2011-03-08T15:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to modify oracle code in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24509#M5547</link>
      <description>If your code is a direct extract from between PROC SQL and your QUIT; lines, then you'll need to run this code in Pass-Through mode I think.&lt;BR /&gt;
&lt;BR /&gt;
Functions like trunc() and partition by aren't SAS functions so your code flags these as an error.&lt;BR /&gt;
&lt;BR /&gt;
Try something from &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003113595.htm&lt;/A&gt; .</description>
      <pubDate>Wed, 09 Mar 2011 09:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-modify-oracle-code-in-proc-SQL/m-p/24509#M5547</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-03-09T09:33:05Z</dc:date>
    </item>
  </channel>
</rss>

