<?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 convert Oracle SQL code to SAS code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813394#M321023</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;BR /&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;has pointed out you can run on it Oracle using SAS SQL pass through.&lt;BR /&gt;However one must remember that SAS and Oracle are different applications each performing SQL processing and each has its own enhancements not available in the other.&lt;BR /&gt;Therefore a better approach is to determine what your code is doing in Oracle and then rewrite&amp;nbsp; ir ia SAS&amp;nbsp; to perform the same tasks.&lt;BR /&gt;Have a good book like Mastering Oracle SQL (Sanjay Mishra et al) or some similar handy to understand the Oracle SQL Syntax.&lt;/P&gt;
&lt;H1 id="title" class="a-spacing-none a-text-normal"&gt;&amp;nbsp;&lt;/H1&gt;</description>
    <pubDate>Sun, 15 May 2022 22:45:43 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2022-05-15T22:45:43Z</dc:date>
    <item>
      <title>How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813384#M321014</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I'm having a trouble converting Power function and double Decode statement to SAS proc sql.&amp;nbsp; Please help me with 2 issues below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ I would like to get the GROUP_ID to match with another table, but the source data is different from the destination, and I don't understand the previous person program as below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;POWER(2,33) * DECODE(IS_NUMBER(SUBSTR( LC.LAB_REFERENCE,1,5)),1,TO_NUMBER(SUBSTR( LC.LAB_REFERENCE,1,5)), NULL) +&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;DECODE( IS_NUMBER(SUBSTR( LC.LAB_REFERENCE,7, LENGTH( LC.LAB_REFERENCE)-6 - (DECODE(INSTR( LC.LAB_REFERENCE,'/R',1),0,0,3)))),&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;1, TO_NUMBER(SUBSTR( LC.LAB_REFERENCE,7, LENGTH( LC.LAB_REFERENCE)-6 - (DECODE(INSTR( LC.LAB_REFERENCE,'/R',1),0,0,3)))),&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;NULL) AS GROUP_ID&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/ This one has double DECODE function.&amp;nbsp; As I would like to create 2 columns for separate Left Len Cost vs. Right Len Cost.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;DECODE(DECODE(LC.ITEM_TYPE,'L',NVL(LC.ITEM_EYE,'B')),'L',TOTAL_COST) AS L_LENS_COST,&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;DECODE(DECODE(LC.ITEM_TYPE,'L',NVL(LC.ITEM_EYE,'B')),'R',TOTAL_COST) AS R_LENS_COST&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 18:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813384#M321014</guid>
      <dc:creator>QHO</dc:creator>
      <dc:date>2022-05-15T18:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813388#M321018</link>
      <description>&lt;P&gt;Why do you need to convert it? You can run this as is from SAS using SQL Passthru.&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 20:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813388#M321018</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-15T20:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813390#M321019</link>
      <description>&lt;P&gt;Figure it out.&amp;nbsp; Here is link to Oracle definition of the &lt;A href="https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions040.htm" target="_self"&gt;DECODE()&lt;/A&gt; function&lt;/P&gt;
&lt;P&gt;Formatting the code will make it easier to see what it is trying to do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;DECODE(
   DECODE(LC.ITEM_TYPE
         ,'L',NVL(LC.ITEM_EYE,'B')
         )
 ,'L',TOTAL_COST
 ) AS L_LENS_COST&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which looks a little bit silly.&amp;nbsp; It is re-coding (decode seems like a misnomer for this function) the L values in ITEM_TYPE to either ITEM_EYE or B.&amp;nbsp; Then it is re-coding L in the result (which is only possible if both ITEM_TYPE and ITEM_EYE is L) to TOTAL_COST.&lt;/P&gt;
&lt;P&gt;So perhaps they meant:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when (lc.item_eye = 'L' and lc.item_type='L') then total_cost end&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2022 00:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813390#M321019</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-16T00:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813392#M321021</link>
      <description>&lt;P&gt;Thanks SASKiwi for your question.&amp;nbsp; I actually don't know how to use SQL Passthru.&amp;nbsp; Do you have an example?&lt;/P&gt;&lt;P&gt;I'm familiar with Proc sql &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 22:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813392#M321021</guid>
      <dc:creator>QHO</dc:creator>
      <dc:date>2022-05-15T22:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813393#M321022</link>
      <description>&lt;P&gt;Thanks Tom.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, it works.&amp;nbsp; Very helpful explanations!&lt;/P&gt;&lt;P&gt;Much appreciations.&lt;/P&gt;&lt;P&gt;Quinn&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 22:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813393#M321022</guid>
      <dc:creator>QHO</dc:creator>
      <dc:date>2022-05-15T22:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813394#M321023</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;BR /&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;has pointed out you can run on it Oracle using SAS SQL pass through.&lt;BR /&gt;However one must remember that SAS and Oracle are different applications each performing SQL processing and each has its own enhancements not available in the other.&lt;BR /&gt;Therefore a better approach is to determine what your code is doing in Oracle and then rewrite&amp;nbsp; ir ia SAS&amp;nbsp; to perform the same tasks.&lt;BR /&gt;Have a good book like Mastering Oracle SQL (Sanjay Mishra et al) or some similar handy to understand the Oracle SQL Syntax.&lt;/P&gt;
&lt;H1 id="title" class="a-spacing-none a-text-normal"&gt;&amp;nbsp;&lt;/H1&gt;</description>
      <pubDate>Sun, 15 May 2022 22:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813394#M321023</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-05-15T22:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813399#M321028</link>
      <description>&lt;P&gt;Here is some sample code designed for SQL Server. Just replace it with your Oracle connection details. Place your unmodified Oracle SQL where it says "Put your SQL Server query here".&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 connect to odbc (noprompt = "server=MyServerName;DRIVER=SQL Server;Trusted Connection=yes;");
  create table Want  as 
  select * from connection to odbc
  (---- Put your SQL Server query here
   )
  ;
  disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 May 2022 22:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813399#M321028</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-15T22:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813400#M321029</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131732"&gt;@Sajid01&lt;/a&gt;&amp;nbsp;- While I generally agree with your approach, sometimes SQL Passthru and Oracle-specific SQL is best. I've often found you have to use Oracle hints to get reasonable query performance for example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 23:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813400#M321029</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-15T23:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813405#M321031</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;</description>
      <pubDate>Mon, 16 May 2022 00:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813405#M321031</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-05-16T00:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813406#M321032</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having another issue with connecting to the database using your sample code.&amp;nbsp; I've contacted our DBA, hopefully the server is down or my path is wrong.&amp;nbsp; Fingers crossed!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;29 CONNECT TO ORACLE (user="XXXXXX" password=XXXXXXXXXXXXXXXXXXX&lt;BR /&gt;30 PATH = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxxxxxx)(PORT=xxxxx))&lt;BR /&gt;31 (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME =xxxxxxxxx)))");&lt;BR /&gt;ERROR: ORACLE connection error: ORA-12541: TNS:no listener.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 00:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813406#M321032</guid>
      <dc:creator>QHO</dc:creator>
      <dc:date>2022-05-16T00:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813408#M321034</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/23244"&gt;@QHO&lt;/a&gt;&amp;nbsp; - Agreed. Your DBA is the best person to figure this out. Looks like you are trying to define the Oracle connection completely in SAS. This is good as that means you don't have to tinker with your TNSNAMES.ORA file.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 02:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813408#M321034</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-16T02:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Oracle SQL code to SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813432#M321047</link>
      <description>&lt;P&gt;Exactly, in my company business users are familiar with queries in a BI application through a drag&amp;amp;drop approach. They can copy the oracle query code that runs in the backgroups and plug it in in the sas code like you decribed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a huge time saver and we have the data directly in sas building up on the users' expertise to make the query and put the filters they require.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 10:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Oracle-SQL-code-to-SAS-code/m-p/813432#M321047</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-05-16T10:53:59Z</dc:date>
    </item>
  </channel>
</rss>

