<?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 Merge Table in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73200#M7280</link>
    <description>I want to create a table by merging the 2 datasets below:&lt;BR /&gt;
&lt;BR /&gt;
My raw datasets like this:&lt;BR /&gt;
&lt;BR /&gt;
Data1:&lt;BR /&gt;
ID         Month&lt;BR /&gt;
123       12/08&lt;BR /&gt;
123       01/09&lt;BR /&gt;
234       07/07&lt;BR /&gt;
456       08/07&lt;BR /&gt;
456       10/07&lt;BR /&gt;
456       11/07&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data2:&lt;BR /&gt;
ID     Month  Name&lt;BR /&gt;
001   01/08   XYZ&lt;BR /&gt;
001   02/08   XYZ&lt;BR /&gt;
001   03/08   XYZ&lt;BR /&gt;
123   12/08   ABC&lt;BR /&gt;
123   01/09   ABC&lt;BR /&gt;
123   02/09   ABC&lt;BR /&gt;
123   03/09   ABC&lt;BR /&gt;
234   07/07   EEE&lt;BR /&gt;
234   08/07   EEE&lt;BR /&gt;
456   08/07   PAS&lt;BR /&gt;
456   09/07   PAS&lt;BR /&gt;
456   10/07   PAS&lt;BR /&gt;
456   11/07   PAS&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Result:&lt;BR /&gt;
ID     Month  Name&lt;BR /&gt;
123   12/08   ABC&lt;BR /&gt;
123   01/09   ABC&lt;BR /&gt;
123   02/09   ABC&lt;BR /&gt;
123   03/09   ABC&lt;BR /&gt;
234   07/07   EEE&lt;BR /&gt;
234   08/07   EEE&lt;BR /&gt;
456   08/07   PAS&lt;BR /&gt;
456   09/07   PAS&lt;BR /&gt;
456   10/07   PAS&lt;BR /&gt;
456   11/07   PAS</description>
    <pubDate>Mon, 09 Feb 2009 05:45:02 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-02-09T05:45:02Z</dc:date>
    <item>
      <title>Merge Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73200#M7280</link>
      <description>I want to create a table by merging the 2 datasets below:&lt;BR /&gt;
&lt;BR /&gt;
My raw datasets like this:&lt;BR /&gt;
&lt;BR /&gt;
Data1:&lt;BR /&gt;
ID         Month&lt;BR /&gt;
123       12/08&lt;BR /&gt;
123       01/09&lt;BR /&gt;
234       07/07&lt;BR /&gt;
456       08/07&lt;BR /&gt;
456       10/07&lt;BR /&gt;
456       11/07&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data2:&lt;BR /&gt;
ID     Month  Name&lt;BR /&gt;
001   01/08   XYZ&lt;BR /&gt;
001   02/08   XYZ&lt;BR /&gt;
001   03/08   XYZ&lt;BR /&gt;
123   12/08   ABC&lt;BR /&gt;
123   01/09   ABC&lt;BR /&gt;
123   02/09   ABC&lt;BR /&gt;
123   03/09   ABC&lt;BR /&gt;
234   07/07   EEE&lt;BR /&gt;
234   08/07   EEE&lt;BR /&gt;
456   08/07   PAS&lt;BR /&gt;
456   09/07   PAS&lt;BR /&gt;
456   10/07   PAS&lt;BR /&gt;
456   11/07   PAS&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Result:&lt;BR /&gt;
ID     Month  Name&lt;BR /&gt;
123   12/08   ABC&lt;BR /&gt;
123   01/09   ABC&lt;BR /&gt;
123   02/09   ABC&lt;BR /&gt;
123   03/09   ABC&lt;BR /&gt;
234   07/07   EEE&lt;BR /&gt;
234   08/07   EEE&lt;BR /&gt;
456   08/07   PAS&lt;BR /&gt;
456   09/07   PAS&lt;BR /&gt;
456   10/07   PAS&lt;BR /&gt;
456   11/07   PAS</description>
      <pubDate>Mon, 09 Feb 2009 05:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73200#M7280</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-09T05:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73201#M7281</link>
      <description>Using a DATA STEP with the MERGE statement and the in= Option for Data2 is the common way to get the result. Both datasets must be sorted by "Id" and "Month".</description>
      <pubDate>Mon, 09 Feb 2009 07:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73201#M7281</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2009-02-09T07:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73202#M7282</link>
      <description>Hi Clau,&lt;BR /&gt;
&lt;BR /&gt;
It looks like you want all the stuff in Data2 which matches an ID value from Data1. The month values in Data1 don't look they're being used for verification, yes?&lt;BR /&gt;
&lt;BR /&gt;
As Andreas suggested, a merge with an IN= option would be a good way to go. Since this is an EG forum, I'll mention there's an alternative way to do this without writing any code.&lt;BR /&gt;
&lt;BR /&gt;
1. Use a Query Task on Data1 to create a new data set containing only the ID column, and only the distinct values in that column. Within the query task, you'd drag ID into the Select and right below that there's a check box for distinct values.&lt;BR /&gt;
2. In a second Query Task, join the newly created data set (let's call it "Distinct") and Data2. In the join window, verify that the join is ID to ID, and change the join type to left or right (as appropriate) so that only matches from data2 are coming in. Then add a filter on the ID column from the Distinct data set so that ID is not missing. You can type a space in the filter value box or just leave it blank for a missing value.&lt;BR /&gt;
&lt;BR /&gt;
We had to include the step of getting just the distinct values first because otherwise the SQL join would create a cartesian product giving you 2*4=8 ID 123 values, for example.</description>
      <pubDate>Mon, 09 Feb 2009 14:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Merge-Table/m-p/73202#M7282</guid>
      <dc:creator>RichardH_sas</dc:creator>
      <dc:date>2009-02-09T14:18:34Z</dc:date>
    </item>
  </channel>
</rss>

