<?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: ETL Question - Merging two tables using proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573915#M75392</link>
    <description>The code seemed to work but im getting a teradata error. This issue might no longer be related to the query in itself but i'm not sure either.&lt;BR /&gt;&lt;BR /&gt;ERROR: Teradata insert: Response limit exceeded.</description>
    <pubDate>Tue, 16 Jul 2019 16:09:25 GMT</pubDate>
    <dc:creator>dwah</dc:creator>
    <dc:date>2019-07-16T16:09:25Z</dc:date>
    <item>
      <title>ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573903#M75389</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, I am trying to write an etl process to update a main table with periodic updates(these updates could either be changes to existing rows or could contain new rows or both)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main table has 5 rows with 2 columns(name and age):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Age&lt;/P&gt;&lt;P&gt;John Doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13&lt;/P&gt;&lt;P&gt;John Smith&amp;nbsp; &amp;nbsp; &amp;nbsp;15&lt;/P&gt;&lt;P&gt;Bo Derek&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&lt;/P&gt;&lt;P&gt;Randy Snow&amp;nbsp; &amp;nbsp;28&lt;/P&gt;&lt;P&gt;Matt Damon&amp;nbsp; &amp;nbsp; 38&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New incoming table(6 rows, one update to the age and 1 new row)&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Age&lt;/P&gt;&lt;P&gt;Bo Derek&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 28&lt;/P&gt;&lt;P&gt;Camilla White&amp;nbsp; &amp;nbsp;39&lt;/P&gt;&lt;P&gt;John Doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13&lt;/P&gt;&lt;P&gt;John Smith&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15&lt;/P&gt;&lt;P&gt;Matt Damon&amp;nbsp; &amp;nbsp; &amp;nbsp; 38&lt;/P&gt;&lt;P&gt;Randy Snow&amp;nbsp; &amp;nbsp; &amp;nbsp;28&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideal Result Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Age&lt;/P&gt;&lt;P&gt;John Doe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13&lt;/P&gt;&lt;P&gt;John Smith&amp;nbsp; &amp;nbsp; &amp;nbsp;15&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bo Derek&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 28&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Randy Snow&amp;nbsp; &amp;nbsp;28&lt;/P&gt;&lt;P&gt;Matt Damon&amp;nbsp; &amp;nbsp; 38&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Camilla White&amp;nbsp; &amp;nbsp;39&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i'm hoping to do is merge the two tables(main_tbl and updt_tbl)&amp;nbsp; into a new table and have "Bo Derek"'s age be updated with the new age in the second table and the insertion of the new row "Camilla White" all to the result_tbl. The repeated rows in the update table should not be appended to the new table to prevent duplicates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table s.result_tbl as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from s.main_tbl, s.updt_tbl&lt;BR /&gt;where main_tbl.name&amp;nbsp; = updt_tbl.name&lt;BR /&gt;order by name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is my current solution, but I don't think that's the right way at all of approaching this. I would prefer to stick with using proc sql; and not having to resort to data steps. What would be the most efficient and effective way of achieving the desired outcome? Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 15:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573903#M75389</guid>
      <dc:creator>dwah</dc:creator>
      <dc:date>2019-07-16T15:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573906#M75390</link>
      <description>Have you tried a data step update?&lt;BR /&gt;&lt;BR /&gt;data s.result_tbl;&lt;BR /&gt;update main_tbl updt_tb;&lt;BR /&gt;by name;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Jul 2019 15:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573906#M75390</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-16T15:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573914#M75391</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276160"&gt;@dwah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main;
input Name    &amp;amp; $20.            Age;
cards;
John Doe        13
John Smith     15
Bo Derek        21
Randy Snow   28
Matt Damon    38
;


data new;
input Name    &amp;amp; $20.            Age;
cards;
Bo Derek          28
Camilla White   39
John Doe          13
John Smith        15
Matt Damon      38
Randy Snow     28
;

proc sql;
create table result as
select coalescec(a.name,b.name) as name ,b.age 
from main a full join new b
on a.name=b.name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jul 2019 16:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573914#M75391</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-16T16:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573915#M75392</link>
      <description>The code seemed to work but im getting a teradata error. This issue might no longer be related to the query in itself but i'm not sure either.&lt;BR /&gt;&lt;BR /&gt;ERROR: Teradata insert: Response limit exceeded.</description>
      <pubDate>Tue, 16 Jul 2019 16:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573915#M75392</guid>
      <dc:creator>dwah</dc:creator>
      <dc:date>2019-07-16T16:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573926#M75393</link>
      <description>Looks like a network time out issue?</description>
      <pubDate>Tue, 16 Jul 2019 16:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/573926#M75393</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-16T16:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: ETL Question - Merging two tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/574114#M75399</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276160"&gt;@dwah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The code seemed to work but im getting a teradata error. This issue might no longer be related to the query in itself but i'm not sure either.&lt;BR /&gt;&lt;BR /&gt;ERROR: Teradata insert: Response limit exceeded.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Oh, your table(s) are in Teradata. That makes a difference.&lt;/P&gt;
&lt;P&gt;I'd be using explicit pass-through SQL and then use a Teradata SQL MERGE. If your source table is in SAS and not already Teradata then I'd upload this table first into the database - either into a staging area or then as a temporary table.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ETL-Question-Merging-two-tables-using-proc-sql/m-p/574114#M75399</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-17T09:56:23Z</dc:date>
    </item>
  </channel>
</rss>

