<?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 Combine multiple SQL into a single step via left join in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Combine-multiple-SQL-into-a-single-step-via-left-join/m-p/498921#M72545</link>
    <description>&lt;P&gt;Appreciate if someone of you guide me to combine the following SQL into one single step via left join.&amp;nbsp;session.incomm table is common for all the below SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Inbox for communication */
create table incomm4 as
select distinct b.identifier as inboxforcommunicationID, b.name as afdeling
from session.incomm a left join qis.rpinboxforcommunication b
on a.inboxforcommunicationID=b.identifier
where b.identifier in ('00000000001','10000000000','10000000001','10000000003')
);
/* createur */
create table incomm5 as
select distinct createdbylogonuserid, left(trim(lastname))||' '||left(trim(firstname)) as creator, creator_duser
from connection to db2(
select 	b.identifier as createdbylogonuserid,
		b.externalidentifier as creator_duser,	
		b.lastname,b.firstname
from session.incomm a  left join qis.rplogonuser b
on a.createdbylogonuserid=b.identifier
);
/**** INFO CLIENT ***/
create table incomm6 as
select x.policyinstanceid , x.customerID, y.value as client_segment from
(select b.identifier as policyinstanceid , b.customerID
from session.incomm a left join qis.rppolicyinstance b
on a.policyinstanceid=b.identifier) as x left join qis.rpcustomerfield y
on  x.customerid=y.customerid where y.externalidentifier='customerSubsegmentGE'
);
/**** INFO Policy ***/
proc sql;
create table incomm8 as
select distinct x.*, y.name as product from
(select b.identifier as policyid   , b.productid
	from session.incomm a left join qis.rppolicy b
	on a.policyid=b.identifier) as x left join qis.rpproduct y
	on x.productid=y.identifier
);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Sep 2018 02:23:33 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2018-09-26T02:23:33Z</dc:date>
    <item>
      <title>Combine multiple SQL into a single step via left join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-multiple-SQL-into-a-single-step-via-left-join/m-p/498921#M72545</link>
      <description>&lt;P&gt;Appreciate if someone of you guide me to combine the following SQL into one single step via left join.&amp;nbsp;session.incomm table is common for all the below SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Inbox for communication */
create table incomm4 as
select distinct b.identifier as inboxforcommunicationID, b.name as afdeling
from session.incomm a left join qis.rpinboxforcommunication b
on a.inboxforcommunicationID=b.identifier
where b.identifier in ('00000000001','10000000000','10000000001','10000000003')
);
/* createur */
create table incomm5 as
select distinct createdbylogonuserid, left(trim(lastname))||' '||left(trim(firstname)) as creator, creator_duser
from connection to db2(
select 	b.identifier as createdbylogonuserid,
		b.externalidentifier as creator_duser,	
		b.lastname,b.firstname
from session.incomm a  left join qis.rplogonuser b
on a.createdbylogonuserid=b.identifier
);
/**** INFO CLIENT ***/
create table incomm6 as
select x.policyinstanceid , x.customerID, y.value as client_segment from
(select b.identifier as policyinstanceid , b.customerID
from session.incomm a left join qis.rppolicyinstance b
on a.policyinstanceid=b.identifier) as x left join qis.rpcustomerfield y
on  x.customerid=y.customerid where y.externalidentifier='customerSubsegmentGE'
);
/**** INFO Policy ***/
proc sql;
create table incomm8 as
select distinct x.*, y.name as product from
(select b.identifier as policyid   , b.productid
	from session.incomm a left join qis.rppolicy b
	on a.policyid=b.identifier) as x left join qis.rpproduct y
	on x.productid=y.identifier
);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Sep 2018 02:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-multiple-SQL-into-a-single-step-via-left-join/m-p/498921#M72545</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-26T02:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combine multiple SQL into a single step via left join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combine-multiple-SQL-into-a-single-step-via-left-join/m-p/499343#M72555</link>
      <description>Since none of the queries is reusing any result from any of the other queries I can't see how they can be combined. Unless that there's succeeding steps that you don't share. &lt;BR /&gt;&lt;BR /&gt;And right now the code is totally in DB2 SQL which would not make this a SAS question. On the other hand, I can't see any DB2 specifics in the code, so it could easily be transformed to implicit SQL, which IMO is easier to read and maintain.</description>
      <pubDate>Thu, 27 Sep 2018 01:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combine-multiple-SQL-into-a-single-step-via-left-join/m-p/499343#M72555</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-09-27T01:53:27Z</dc:date>
    </item>
  </channel>
</rss>

