<?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 a problem in merging many to many tables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462910#M14398</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 289px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20587i479664AE7B37A99B/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 385px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20588iF641C559E54831D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 452px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20589iA33AA5FDC4201BA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to make the third table using the first two tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought of the following syntax:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table t1 as select *&lt;/P&gt;&lt;P&gt;from t3 a left join t2 b&lt;/P&gt;&lt;P&gt;on a.year=b.year and a.id=b.id;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it only showed the first observation each year from the table 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to figure out.&lt;/P&gt;</description>
    <pubDate>Thu, 17 May 2018 00:19:57 GMT</pubDate>
    <dc:creator>withpeople86</dc:creator>
    <dc:date>2018-05-17T00:19:57Z</dc:date>
    <item>
      <title>a problem in merging many to many tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462910#M14398</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 289px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20587i479664AE7B37A99B/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 385px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20588iF641C559E54831D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 452px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20589iA33AA5FDC4201BA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to make the third table using the first two tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought of the following syntax:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table t1 as select *&lt;/P&gt;&lt;P&gt;from t3 a left join t2 b&lt;/P&gt;&lt;P&gt;on a.year=b.year and a.id=b.id;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it only showed the first observation each year from the table 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to figure out.&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 00:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462910#M14398</guid>
      <dc:creator>withpeople86</dc:creator>
      <dc:date>2018-05-17T00:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: a problem in merging many to many tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462922#M14400</link>
      <description>&lt;P&gt;pics or screen shots doesn't help. Please post the values as text&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 02:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462922#M14400</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-17T02:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: a problem in merging many to many tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462933#M14401</link>
      <description>&lt;P&gt;See my footnotes for how to post example data and code.&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 06:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/462933#M14401</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-17T06:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: a problem in merging many to many tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/463038#M14408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/210501"&gt;@withpeople86&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 289px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20587i479664AE7B37A99B/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 385px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20588iF641C559E54831D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 452px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20589iA33AA5FDC4201BA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I would like to make the third table using the first two tables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought of the following syntax:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; create table t1 as select *&lt;/P&gt;
&lt;P&gt;from t3 a left join t2 b&lt;/P&gt;
&lt;P&gt;on a.year=b.year and a.id=b.id;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it only showed the first observation each year from the table 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to figure out.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which table is t3? which is t2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What formats are currently involved with the variables? When you compare or join with = the values have to actually be equal. Numeric variables with decimals portions suppressed by "look" the same when examining tables but not be equal. If the variables are text you run into potential issues with leading characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;did you try&lt;/P&gt;
&lt;PRE&gt;proc sql; 
   create table t1 as 
   select a.*,b.var2,b.var3
   from t3 a left join t2 b
   on a.year=b.year and a.id=b.id;
quit;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 15:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/463038#M14408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-17T15:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: a problem in merging many to many tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/463694#M14432</link>
      <description>&lt;P&gt;Your table T! has one record with YEAR=3, ID=4.&amp;nbsp;&amp;nbsp; And T2 has two such records, so T3 should also have two such records, but you posting shows only one.&amp;nbsp; If that&amp;nbsp; is an error, than this program takes advantage of the fact that both T1 and T2 are sorted by ID/YEAR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
  input year id var1 :$1.;
datalines;
1 1 a
2 1 b
3 1 a
4 1 b
1 2 b
2 2 b
3 2 a
4 2 b
1 3 b
2 3 b
3 3 b
4 3 c
1 4 c
2 4 a
3 4 b
4 4 a
run;
data t2;
  input year id var2 var3;
datalines;
1 1 1 1
1 1 1 2
1 1 1 13
2 1 1 3
1 2 0 14
1 2 0 5
3 2 0 5
2 3 1 2
2 3 1 3
4 3 1 5
3 4 1 3
3 4 0 5
4 4 0 2
4 4 1 1
run;
data want;
  merge t1 t2;
  by id year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program works because T1 has only 1 record for each YEAR/ID combination.&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 03:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/a-problem-in-merging-many-to-many-tables/m-p/463694#M14432</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-21T03:33:36Z</dc:date>
    </item>
  </channel>
</rss>

