<?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 values after join in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424805#M27375</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@schlotty23 wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, the first one I posted had distinct for both columns, here's an updated version:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 312px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17636iA8DDD69A177F0280/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you have duplicates....in both data sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What makes you think it's unique? Are you sure you're using the correct files, joining on the correct variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;on &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;a.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;campaign_id&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;_id&lt;/STRONG&gt; &lt;/FONT&gt;= b.&lt;/SPAN&gt;&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;a.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;campaign_id&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt; is not null&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you have two&amp;nbsp;variables or should the second one be campaign_id_id?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Either way, you have duplicates, so you'll get multiples.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2018 01:36:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-04T01:36:46Z</dc:date>
    <item>
      <title>Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424780#M27366</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm assuming this is a simple answer but here it goes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables for an email campaign: one with engagement levels, the other with revenue. I have the data rolled up to a regional grouping, and the unique ID's for each campaign are in both tables, so that is what I am using to join the two tables together. I basically want by campaign, by group - the engagements and revenue combined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I am getting three matching rows returned now for each value that should be unique.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that there are some campaigns without revenue, so I am using a left join to show the campaigns in the engagement table, and then also revenue where there is a match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;create table&amp;nbsp;match as&lt;BR /&gt;select&lt;BR /&gt;distinct a.campaign_id,&lt;BR /&gt;a.region,&lt;BR /&gt;a.program,&lt;BR /&gt;a.processed_dttm,&lt;BR /&gt;a.sent,&lt;BR /&gt;a.open,&lt;BR /&gt;a.click,&lt;BR /&gt;b.bookings,&lt;BR /&gt;b.revenue&lt;BR /&gt;from table.engagement&amp;nbsp;a&lt;BR /&gt;left join&lt;BR /&gt;table.revenue&amp;nbsp;b&lt;BR /&gt;on a.&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;_id = b.&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;&lt;BR /&gt;where a.&lt;SPAN&gt;campaign_id&lt;/SPAN&gt; is not null&lt;BR /&gt;group by 1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you help ahead of time!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424780#M27366</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-03T23:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424783#M27367</link>
      <description>&lt;P&gt;That means one of your tables has duplicates. Figure out which one first.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424783#M27367</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-03T23:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424784#M27368</link>
      <description>&lt;P&gt;Just checked both tables and there are no duplicates. There's a unique row for each row with the rolled up data.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424784#M27368</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-03T23:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424786#M27369</link>
      <description>&lt;P&gt;Sorry, I meant to say unique row for each group of rolled up data in the table.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424786#M27369</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-03T23:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424787#M27370</link>
      <description>&lt;P&gt;Check your log, do you have an error in your code?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;on a.&lt;/SPAN&gt;&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_id&lt;/STRONG&gt;&lt;/FONT&gt; = b.&lt;/SPAN&gt;&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Otherwise, If that join is correct with the variable names then you shouldn't get duplicates.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please post the output from the following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(campaign_id_id) as N, count(distinct campaign_id_id) as N_Distinct
from table.engagement;
select count(campaign_id) as N, count(distinct campaign_id) as N_Distinct
from table.revenue;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424787#M27370</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-03T23:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424790#M27371</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 224px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17635iAC2E355A17EE4D37/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424790#M27371</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-03T23:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424793#M27372</link>
      <description>&lt;P&gt;Sorry, the first one I posted had distinct for both columns, here's an updated version:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 312px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17636iA8DDD69A177F0280/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 23:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424793#M27372</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-03T23:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424796#M27373</link>
      <description>&lt;P&gt;When your N is 2458 and the N_distinct is 887 then you either have one of the campaign_id values duplicated about 1570 times or many of the campaign_id values have one or more duplicates, averaging about 2.8 observations per id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps your Where clause is referencing the wrong Id variable?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 00:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424796#M27373</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-04T00:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424805#M27375</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@schlotty23 wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, the first one I posted had distinct for both columns, here's an updated version:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 312px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17636iA8DDD69A177F0280/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you have duplicates....in both data sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What makes you think it's unique? Are you sure you're using the correct files, joining on the correct variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;on &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;a.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;campaign_id&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;_id&lt;/STRONG&gt; &lt;/FONT&gt;= b.&lt;/SPAN&gt;&lt;SPAN&gt;campaign_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;a.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;campaign_id&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt; is not null&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you have two&amp;nbsp;variables or should the second one be campaign_id_id?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Either way, you have duplicates, so you'll get multiples.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 01:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/424805#M27375</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-04T01:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values after join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/425028#M27381</link>
      <description>&lt;P&gt;Figured it out. I had to join both on the campaign id AND the region in the join in order to obtain the desired results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 19:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-values-after-join/m-p/425028#M27381</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-01-04T19:51:43Z</dc:date>
    </item>
  </channel>
</rss>

