<?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: Duplicate Rows After Left Join in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427259#M27522</link>
    <description>&lt;P&gt;I think that you may be misunderstanding what the DISTINCT actually attempts to do. It gets distinct combinations of ALL variables on the select statement not just the first variable.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2018 16:39:55 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-12T16:39:55Z</dc:date>
    <item>
      <title>Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427105#M27503</link>
      <description>&lt;P&gt;Simple question probably, but I keep arranging and rearranging&amp;nbsp; distinct and group by in the code and I'm not getting anything different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables that share an ID between the two of them. Let's say table a has revenue data associated with each ID and table two has an instance where two titles are associated with the same ID. I use a left join of table an and ask for a distinct ID, and even group by, but I keep getting two row back for that ID, one for each name from table&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table tableau.metadata_match as 
select
distinct a.product_id,
a.region,
b.product_name,
a.transactions,
a.revenue
from table a
left join 
table b 
on a.product_id = b.product_id;&lt;BR /&gt;group by 1, 2
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It returns these rows repeating the revenue. What I really want is only row for this.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;product_id&lt;/TD&gt;&lt;TD&gt;region&lt;/TD&gt;&lt;TD&gt;product_name&lt;/TD&gt;&lt;TD&gt;transactions&lt;/TD&gt;&lt;TD&gt;revenue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54321&lt;/TD&gt;&lt;TD&gt;SW&lt;/TD&gt;&lt;TD&gt;product_a&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;56.11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54321&lt;/TD&gt;&lt;TD&gt;SW&lt;/TD&gt;&lt;TD&gt;product_b&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;56.11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sd&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 05:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427105#M27503</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-12T05:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427106#M27504</link>
      <description>&lt;P&gt;I see few problem with the sql query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should remove group by statement becuase I do not find any aggregate function being used in the select clause.&lt;/P&gt;
&lt;P&gt;Then try again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 05:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427106#M27504</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2018-01-12T05:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427113#M27507</link>
      <description>&lt;P&gt;Which match in the second table should be selected?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post some example input-datasets as data-steps, so that we see what you have.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 06:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427113#M27507</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-01-12T06:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427124#M27508</link>
      <description>&lt;P&gt;The problem is that you still have product in your query and there are 2 different values which gives you 2 rows of data.&lt;/P&gt;
&lt;P&gt;If you remove it you will get 1 row.&lt;/P&gt;
&lt;P&gt;But if you still need product in your result you need to descide which one to keep, as Andreas says &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 08:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427124#M27508</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-01-12T08:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427259#M27522</link>
      <description>&lt;P&gt;I think that you may be misunderstanding what the DISTINCT actually attempts to do. It gets distinct combinations of ALL variables on the select statement not just the first variable.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 16:39:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427259#M27522</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-12T16:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427273#M27527</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I posted fake data to show an example of the scenario and what output I'm receiving. However, in the real scenario, If I need to specify just one of these, how do I do it by choosing either randomly or based&amp;nbsp;off of occurrence using a date field (first occurrence, most recent occurrence)?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 16:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427273#M27527</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-12T16:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows After Left Join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427274#M27528</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;If I need to specify just one of these, how do I do it by choosing either randomly or based&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;off of occurrence using a date field (first occurrence, most recent occurrence)?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 16:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-After-Left-Join/m-p/427274#M27528</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-12T16:59:28Z</dc:date>
    </item>
  </channel>
</rss>

