<?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: How to merge two tables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705882#M216594</link>
    <description>Have you tried the suggested solutions to see if they work for you? I would also recommend generating a Minimum Complete Example that covers as many scenarios you can think of and test it first. Then apply it to your actual data.&lt;BR /&gt;&lt;BR /&gt;Either way, a merge is a backup that is guaranteed to work.</description>
    <pubDate>Tue, 15 Dec 2020 00:19:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-12-15T00:19:53Z</dc:date>
    <item>
      <title>How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705849#M216581</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset A with 18000 obs and 900 columns (Name, Status, ect.), and dataset B with 200 obs and two columns (Name and Status).&amp;nbsp;&amp;nbsp; All the 200 "name" in dataset B come from dataset A, but with new updated "status".&amp;nbsp; I would like to merge dataset A and B so that I could update the "status" column in dataset A.&amp;nbsp; In other words, my final purpose is to get full dataset A, with the same&amp;nbsp;18000 obs and 900 columns, and&amp;nbsp;the "Status" column should include updating "status" column from dataset B of the same "Name".&amp;nbsp; Please advice how to approach it, thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 21:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705849#M216581</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-12-14T21:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705864#M216583</link>
      <description>&lt;P&gt;Does the big data set have duplicates of the same "Name" variable?&lt;/P&gt;
&lt;P&gt;If so , do you want to update ALL of the status to the same value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this situation, then sort both data sets by Name, and merge by Name.&lt;/P&gt;
&lt;P&gt;As long as the variable Status is the correct type then what you want will be attempted.&lt;/P&gt;
&lt;P&gt;If the status variable is character and has different lengths you will get a warning about such and that you may have truncated data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have multiple names in the big set and only want specific records updated from the small set you need to provide additional information to match the data so merge will work correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have one value in the big set with possibly multiple records with the same name in the small set you would use UPDATE instead of Merge but the data again needs to be sorted by name and then use :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; update bigset smallset;&lt;/P&gt;
&lt;P&gt;by name;&lt;/P&gt;
&lt;P&gt;The order on the Update statement is important. You can update the Bigset by using that instead of Want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be aware: update will add records if there are Names in the smallset that do not match exactly with Names in the big set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the small data set have duplicates of the "Name" variable? If so you may need to provide additional information on how to correctly apply the merge.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 22:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705864#M216583</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-14T22:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705872#M216586</link>
      <description>&lt;P&gt;Both datasets have the same variable names, and same length and same characters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 23:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705872#M216586</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-12-14T23:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705874#M216588</link>
      <description>And I have sorted both datasets too.</description>
      <pubDate>Mon, 14 Dec 2020 23:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705874#M216588</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-12-14T23:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705877#M216591</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;And I have sorted both datasets too.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the question about duplicate VALUES?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge big small;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is the basic code.&lt;/P&gt;
&lt;P&gt;BUT if Small has a duplicate value for a name and Big does not then you get multiple output records for that name.&lt;/P&gt;
&lt;P&gt;If Big has a name value duplicated and Small doesn't then all the duplicated name values in Big will get the same "status" from Small.&lt;/P&gt;
&lt;P&gt;If BOTH have duplicates then the result can be very unpredictable and seldom as desired.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 23:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705877#M216591</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-14T23:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705880#M216593</link>
      <description>&lt;P&gt;When I sorted, I use nodup function to remove both duplicated name in both datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 00:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705880#M216593</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-12-15T00:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705882#M216594</link>
      <description>Have you tried the suggested solutions to see if they work for you? I would also recommend generating a Minimum Complete Example that covers as many scenarios you can think of and test it first. Then apply it to your actual data.&lt;BR /&gt;&lt;BR /&gt;Either way, a merge is a backup that is guaranteed to work.</description>
      <pubDate>Tue, 15 Dec 2020 00:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-two-tables/m-p/705882#M216594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-15T00:19:53Z</dc:date>
    </item>
  </channel>
</rss>

