<?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: Merge two tables with douplicated data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838410#M331493</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436254"&gt;@sebastianmendez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastianmendez_0-1665660658675.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76128i848AAA263336FF00/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastianmendez_0-1665660658675.png" alt="sebastianmendez_0-1665660658675.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If any of your data steps have multiple observations with the same value of ID you should provide an example with some of the repeated values.&lt;/P&gt;
&lt;P&gt;If BOTH data sets have multiple observations with the same value of ID then it is critical that you show example data and the desired result.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 14:43:37 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-13T14:43:37Z</dc:date>
    <item>
      <title>Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838359#M331471</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a novice at SAS and i would ask you how I can do a merge in these conditions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have Table1(IDs, xvariable), and i have a smaller one, Table2(IDs, xvariable). Both tables share some IDs, but i want to keep those in Table2 (and not those in Table1, for those that are in both tables). Sometimes the data (xvariable) is different for the same ID, but data in Table2 is more truthful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 10:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838359#M331471</guid>
      <dc:creator>sebastianmendez</dc:creator>
      <dc:date>2022-10-13T10:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838363#M331473</link>
      <description>&lt;P&gt;Can you post some example of what your data looks like and what you expect as result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Makes it easier to provide a usable code answer.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 10:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838363#M331473</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-10-13T10:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838367#M331475</link>
      <description>&lt;P&gt;Something like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastianmendez_0-1665660658675.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76128i848AAA263336FF00/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastianmendez_0-1665660658675.png" alt="sebastianmendez_0-1665660658675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 11:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838367#M331475</guid>
      <dc:creator>sebastianmendez</dc:creator>
      <dc:date>2022-10-13T11:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838391#M331485</link>
      <description>&lt;P&gt;To me it looks like a LEFT JOIN.&lt;/P&gt;
&lt;P&gt;For variableX, use the COALESCE function.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 12:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838391#M331485</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-10-13T12:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838395#M331486</link>
      <description>&lt;P&gt;That is a simple data step MERGE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge table1 table2;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 13:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838395#M331486</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-13T13:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838397#M331487</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input ID X $;
datalines;
1 a 
2 b 
3 a 
4 b 
5 b 
6 c 
;

data two;
input ID X $;
datalines;
1 c 
8 b 
9 b 
;

data want;
   merge one two;
   by ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 13:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838397#M331487</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-10-13T13:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838410#M331493</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436254"&gt;@sebastianmendez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastianmendez_0-1665660658675.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76128i848AAA263336FF00/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastianmendez_0-1665660658675.png" alt="sebastianmendez_0-1665660658675.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If any of your data steps have multiple observations with the same value of ID you should provide an example with some of the repeated values.&lt;/P&gt;
&lt;P&gt;If BOTH data sets have multiple observations with the same value of ID then it is critical that you show example data and the desired result.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 14:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838410#M331493</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-13T14:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838413#M331494</link>
      <description>Well, i thought i did that.&lt;BR /&gt;You can see the ID 1 is present in both tables. And the desired result is keep the observation (ID1) from the table 2.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2022 14:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838413#M331494</guid>
      <dc:creator>sebastianmendez</dc:creator>
      <dc:date>2022-10-13T14:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838420#M331496</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436254"&gt;@sebastianmendez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well, i thought i did that.&lt;BR /&gt;You can see the ID 1 is present in both tables. And the desired result is keep the observation (ID1) from the table 2.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The fact that there are ID values that can appear in both datasets was already covered by the data in the photographs you posted.&amp;nbsp; But that was not the question that was asked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question was whether or not the ID value uniquely identifies an observation (in either dataset individually).&amp;nbsp; Your data did not show any cases where the same ID value appeared more than once in the same dataset.&amp;nbsp; So the question is whether that is possible with your data or not.&amp;nbsp; &amp;nbsp;If the same ID can appear multiple times in one (or both) of the dataset will require a more complicated solution.&amp;nbsp; And also more explanation from you about what output you would want in that situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838420#M331496</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-13T15:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables with douplicated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838423#M331499</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436254"&gt;@sebastianmendez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well, i thought i did that.&lt;BR /&gt;You can see the ID 1 is present in both tables. And the desired result is keep the observation (ID1) from the table 2.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I should have provided an example of what I meant. Sorry, but I couldn't edit your pictures.&lt;/P&gt;
&lt;P&gt;Stealing from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; , suppose that your data actually looked like&lt;/P&gt;
&lt;P&gt;(the simpler case of only one data set with duplicate id values:&lt;/P&gt;
&lt;P&gt;Case 1: data set One is the only one with duplicates of ID&lt;/P&gt;
&lt;PRE&gt;data one;
input ID X $;
datalines;
1 a 
1 z
2 b 
3 a 
4 b 
5 b 
6 c 
;

data two;
input ID X $;
datalines;
1 c 
8 b 
9 b 
;&lt;/PRE&gt;
&lt;P&gt;Case 2: where data set 2 has duplicates of Id&lt;/P&gt;
&lt;PRE&gt;data one;
input ID X $;
datalines;
1 a 
2 b 
3 a 
4 b 
5 b 
6 c 
;

data two;
input ID X $;
datalines;
1 c 
1 w
8 b 
9 b 
;&lt;/PRE&gt;
&lt;P&gt;Case 3: both sets have duplicates of Id&lt;/P&gt;
&lt;PRE&gt;data one;
input ID X $;
datalines;
1 a 
1 h
1 m
1 s
2 b 
3 a 
4 b 
5 b 
6 c 
;

data two;
input ID X $;
datalines;
1 c 
1 z
8 b 
9 b 
;&lt;/PRE&gt;
&lt;P&gt;If you have any of these cases you need to consider what you expect for a result and show that. The last one can be very complicated depending on exact expectation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-tables-with-douplicated-data/m-p/838423#M331499</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-13T15:32:30Z</dc:date>
    </item>
  </channel>
</rss>

