<?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 sas proc sql equivalent to oracle CONNECT BY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515522#M139101</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am a SAS user, and I have a sql code which I don't know how to translate to SAS CODE. Can you help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(SELECT DISTINCT E.COMMENT FROM&amp;nbsp;table E,(SELECT DECODE(level,1, 'A',&lt;BR /&gt;2, 'B',&lt;BR /&gt;3, 'C',&lt;BR /&gt;4, 'D',&lt;BR /&gt;5, 'E',&lt;BR /&gt;6, 'F',&lt;BR /&gt;7, 'G',&lt;BR /&gt;8, 'H',&lt;BR /&gt;9, 'I',&lt;BR /&gt;10, 'J',) n&lt;BR /&gt;FROM dual&lt;BR /&gt;CONNECT BY level &amp;lt;=10) l&lt;BR /&gt;WHERE E.COMMENT LIKE l.n)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advanced &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Nov 2018 11:35:14 GMT</pubDate>
    <dc:creator>sandradinis</dc:creator>
    <dc:date>2018-11-23T11:35:14Z</dc:date>
    <item>
      <title>sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515522#M139101</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am a SAS user, and I have a sql code which I don't know how to translate to SAS CODE. Can you help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(SELECT DISTINCT E.COMMENT FROM&amp;nbsp;table E,(SELECT DECODE(level,1, 'A',&lt;BR /&gt;2, 'B',&lt;BR /&gt;3, 'C',&lt;BR /&gt;4, 'D',&lt;BR /&gt;5, 'E',&lt;BR /&gt;6, 'F',&lt;BR /&gt;7, 'G',&lt;BR /&gt;8, 'H',&lt;BR /&gt;9, 'I',&lt;BR /&gt;10, 'J',) n&lt;BR /&gt;FROM dual&lt;BR /&gt;CONNECT BY level &amp;lt;=10) l&lt;BR /&gt;WHERE E.COMMENT LIKE l.n)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advanced &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 11:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515522#M139101</guid>
      <dc:creator>sandradinis</dc:creator>
      <dc:date>2018-11-23T11:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515526#M139103</link>
      <description>&lt;P&gt;please give sample &amp;nbsp;input and output, someone will help you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 11:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515526#M139103</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-11-23T11:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515529#M139105</link>
      <description>&lt;P&gt;the idea is to query this into a not in clause... like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT *&lt;BR /&gt;FROM&amp;nbsp;table CB&lt;BR /&gt;LEFT JOIN CODE_TABLE CCBR on (CB.CODE_ID = CCBR.ID)&lt;BR /&gt;WHERE CB.CODE_ID NOT IN (108, 112, 113, 110) AND&lt;BR /&gt;CB.COMMENT not in(&lt;SPAN&gt;(SELECT DISTINCT E.COMMENT FROM&amp;nbsp;table E,(SELECT DECODE(level,1, 'A',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2, 'B',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3, 'C',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4, 'D',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5, 'E',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6, 'F',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7, 'G',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8, 'H',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;9, 'I',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10, 'J',) n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM dual&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CONNECT BY level &amp;lt;=10) l&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE E.COMMENT LIKE l.n)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 11:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515529#M139105</guid>
      <dc:creator>sandradinis</dc:creator>
      <dc:date>2018-11-23T11:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515541#M139113</link>
      <description>&lt;P&gt;What do you mean by "&lt;SPAN&gt;&amp;nbsp;translate to SAS CODE"?&amp;nbsp; Do you want a datastep?&amp;nbsp; Or do you mean ANSI SQL?&amp;nbsp; Where is the data located, is it in a database, or in a SAS dataset?&amp;nbsp; Do you have any documentation on what that code is supposed to do?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I mean I can give some pointers, but hard to re-factor code without knowing really anything about it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;decode(&amp;lt;var&amp;gt;,&amp;lt;code&amp;gt;,&amp;lt;decode&amp;gt;[,&amp;lt;code&amp;gt;,&amp;lt;decode&amp;gt;]) - this is basically an if then block.&amp;nbsp; If var = code then the decode value will be returned.&amp;nbsp; You can do this in ansi sql with case statements, e.g.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;case level when 1 then "A"
                 when 2 then "B"
                 ...
                 else . end as n&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;(note that I don't shout my code at you).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dual is not in ansi sql would need to know how it is being used in this instance.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Connect by I have never used, nor seen used.&amp;nbsp; I presume its like a join.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The rest of the code is pretty self explanatory.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 13:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515541#M139113</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-23T13:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515569#M139127</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Maybe i&amp;nbsp;&lt;/SPAN&gt;have not explained myself well, I need to translate the following query to sas code. I have in sas the datasets that correspond to the oracle tables. But since I do not know very well what the connect by does in oracle, I do not know how to translate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oracle query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT *&lt;BR /&gt;FROM k.CRAN_TABLE CB&lt;BR /&gt;LEFT JOIN k.CODE_CRAN_REASON CCBR on (CB.REASON_ID = CCBR.ID)&lt;BR /&gt;WHERE (CB.REASON_ID &amp;lt;&amp;gt; 109 OR (CB.REASON_ID = 109 and&lt;BR /&gt;CB.COMMENT not &lt;SPAN&gt;like&amp;nbsp;&lt;/SPAN&gt;(SELECT DISTINCT E.COMMENT FROM k.CRAN_BLACK E,(SELECT DECODE(level,1, 'zz',&lt;BR /&gt;2, 'aa',&lt;BR /&gt;3, 'bb',&lt;BR /&gt;4, 'cc',&lt;BR /&gt;5, 'dd',&lt;BR /&gt;6, 'ee',&lt;BR /&gt;7, 'ff',&lt;BR /&gt;8, 'gg',&lt;BR /&gt;9, 'ii',&lt;BR /&gt;10, 'jj',&lt;BR /&gt;) n&lt;BR /&gt;FROM dual&lt;BR /&gt;CONNECT BY level &amp;lt;=10&lt;BR /&gt;) l&lt;BR /&gt;WHERE E.COMMENT LIKE l.n))));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;somthing like doing in the where clause:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;reason_id &amp;lt;&amp;gt; 109 or reason_id = 109 and comment_open not like '%DESC%'&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;But the&amp;nbsp;&lt;SPAN&gt;'%DESC%'&amp;nbsp;can have the following values:&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'zz',&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'aa',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'bb',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'cc',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'dd',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'ee',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'ff',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'gg',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'ii',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'jj',&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe there is an easier way to do it, but I do not know how.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 15:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515569#M139127</guid>
      <dc:creator>sandradinis</dc:creator>
      <dc:date>2018-11-23T15:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql equivalent to oracle CONNECT BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515583#M139135</link>
      <description>&lt;P&gt;You keep referring to "sas code", but SAS code is datastep.&amp;nbsp; There is a proc sql component of Base SAS which can run ANSI SQL statements.&amp;nbsp; As for what connect by does, as I said, I have never used or seen it used.&amp;nbsp; Its not a SAS function, therefore asking here really wont help much.&amp;nbsp; Better to read up on the oracle sites:&lt;BR /&gt;&lt;A href="https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm" target="_blank"&gt;https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:489772591421" target="_blank"&gt;https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:489772591421&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then start looking at ways of doing something similar in SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 15:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-proc-sql-equivalent-to-oracle-CONNECT-BY/m-p/515583#M139135</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-23T15:43:42Z</dc:date>
    </item>
  </channel>
</rss>

