<?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: join two Oracle tables passthrough in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791083#M253330</link>
    <description>&lt;P&gt;First, why are you not happy with your current solution?&lt;/P&gt;
&lt;P&gt;Second, this is pure Oracle PL SQL. If intend to stick with that, you should probably turn to an Oracle forum instead.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jan 2022 07:47:31 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2022-01-20T07:47:31Z</dc:date>
    <item>
      <title>join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791074#M253324</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets in oracle test1 and test2 and test1 has 3 columns pid, mid and sid which we need to concatenate to form a join key premid1 so that we can join to premid in test2 table in oracle&amp;nbsp;&lt;/P&gt;&lt;P&gt;Test1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;State&lt;/TD&gt;&lt;TD&gt;PID&lt;/TD&gt;&lt;TD&gt;MID&lt;/TD&gt;&lt;TD&gt;SID&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;MDT&lt;/TD&gt;&lt;TD&gt;RCRD_IND&lt;/TD&gt;&lt;TD&gt;SCOUNT&lt;/TD&gt;&lt;TD&gt;MFLAG&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;100988&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;520650000&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;202111&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;100345&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;56341040&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;202111&lt;/TD&gt;&lt;TD&gt;N&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;N&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to form premid1 using lpad and concatenation of PID,MID and SID to form join key (premid1) and also have filters like in code below to select records from test1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Test2&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;State&lt;/TD&gt;&lt;TD&gt;Prem_ID&lt;/TD&gt;&lt;TD&gt;SPL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;000100988-0700-000520650000&lt;/TD&gt;&lt;TD&gt;23540&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;000100345-0001-000056341040&lt;/TD&gt;&lt;TD&gt;42522&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VA&lt;/TD&gt;&lt;TD&gt;000200346-0009-000036984700&lt;/TD&gt;&lt;TD&gt;34521&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now it has Prem_ID&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used below code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL ;&lt;BR /&gt;CONNECT to ORACLE as ORA(authdomain=xxxx path= xxxx connection=global);&lt;BR /&gt;Create Table pt_level as&lt;BR /&gt;Select * From CONNECTION TO ORA&lt;BR /&gt;(&lt;BR /&gt;WITH TMP_HDR AS&lt;BR /&gt;(&lt;BR /&gt;select&lt;BR /&gt;Case when SS.State = 'VA'&lt;BR /&gt;then LPAD (ss.PID, 9, 0) || '-' || LPAD (ss.MID, 4, 0) || '-' || LPAD (ss.SID,12,0)&lt;BR /&gt;else 'ERROR'&lt;BR /&gt;End as prem_id1,&lt;BR /&gt;SS.state,&lt;BR /&gt;ss.amount&lt;BR /&gt;&lt;BR /&gt;From&lt;BR /&gt;M_v.TEST1 SS&lt;BR /&gt;Where State = 'VA'&lt;BR /&gt;AND MDT= 202112&lt;BR /&gt;and RCRD_IND = 'Y'&lt;BR /&gt;and SCOUNT = 1&lt;BR /&gt;and MFLAG = 'Y'&lt;BR /&gt;),&lt;/P&gt;&lt;P&gt;TMP_DTL AS&lt;BR /&gt;(&lt;BR /&gt;SELECT DISTINCT&lt;BR /&gt;SP.STATE,&lt;BR /&gt;SP.PID,&lt;BR /&gt;SP.SID&lt;BR /&gt;PC.SPL,&lt;BR /&gt;sp.amount&lt;BR /&gt;&lt;BR /&gt;From TMP_HDR SP&lt;BR /&gt;left JOIN TEST2 PC on SP.STATE = PC.STATE&lt;BR /&gt;and SP.PREMID1 = PC.PREM_ID&lt;/P&gt;&lt;P&gt;GROUP BY STATE,PID,SID&lt;BR /&gt;),&lt;BR /&gt;SELECT H.*&lt;BR /&gt;FROM TMP_DTL H&lt;BR /&gt;&lt;BR /&gt;);&lt;BR /&gt;DISCONNECT FROM ORACLE ;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way i can try to join both tables ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help . Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 04:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791074#M253324</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2022-01-20T04:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791083#M253330</link>
      <description>&lt;P&gt;First, why are you not happy with your current solution?&lt;/P&gt;
&lt;P&gt;Second, this is pure Oracle PL SQL. If intend to stick with that, you should probably turn to an Oracle forum instead.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 07:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791083#M253330</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-01-20T07:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791099#M253342</link>
      <description>&lt;P&gt;I do not think you need to make it that complicated. Something like this should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL ;
CONNECT to ORACLE as ORA(authdomain=xxxx path= xxxx connection=global);
Create Table pt_level as
Select * From CONNECTION TO ORA
(select
    test1.STATE,
    test1.PID,
    test1.SID
    test2.SPL,
    test1.amount
 from  
    test1 left join test2 on
	  test1.state=test2.state and 
	  test2.PREM_ID=LPAD (test1.PID, 9, 0) || '-' || LPAD (test1.MID, 4, 0) || '-' || LPAD (test1.SID,12,0)
  where 
	test1.state='VA' and 
	test1.MDT= 202112 and
    test1.RCRD_IND = 'Y' and
    test1.SCOUNT = 1 and
    test1.MFLAG = 'Y'
  );	

DISCONNECT FROM ORACLE ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jan 2022 09:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791099#M253342</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-01-20T09:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791188#M253375</link>
      <description>Hi ,&lt;BR /&gt;I am checking this one .&lt;BR /&gt;&lt;BR /&gt;Thank you so much for helping</description>
      <pubDate>Thu, 20 Jan 2022 16:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791188#M253375</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2022-01-20T16:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791189#M253376</link>
      <description>Hi ,&lt;BR /&gt;I am checking this one&lt;BR /&gt;&lt;BR /&gt;Thank you so much for helping</description>
      <pubDate>Thu, 20 Jan 2022 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791189#M253376</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2022-01-20T16:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: join two Oracle tables passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791753#M253665</link>
      <description>Thank you so much for all your help</description>
      <pubDate>Mon, 24 Jan 2022 04:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-two-Oracle-tables-passthrough/m-p/791753#M253665</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2022-01-24T04:40:10Z</dc:date>
    </item>
  </channel>
</rss>

