<?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: Join Condition to get the data from both the tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678077#M204620</link>
    <description>&lt;P&gt;What if one of the datasets has no matches? And are the segments unique in have1?&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 13:09:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-20T13:09:16Z</dc:date>
    <item>
      <title>Join Condition to get the data from both the tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678066#M204617</link>
      <description>&lt;P&gt;I've the datasets as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have1;
    input Segment $ Expenses RC;
    datalines;
7183_AS1 1234.50 453.97 
7183_AS2 654.78 325.98 
;
run;

data have2;
    input Segment $ Country $ Currency $;
    datalines;
7183_AS1 USA Dollar
7183_AS1 USA Dollar
7183_AS1 USA Dollar
7183_AS2 USA Dollar
7183_AS2 USA Dollar
;
run;&lt;/PRE&gt;
&lt;P&gt;Now I want to get the results as below. I tried with&amp;nbsp;right join and inner join but it didn't worked either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Segment	Country	Currency Expenses RC
7183_AS1  USA	Dollar	1234.50	453.97
7183_AS1  USA	Dollar	1234.50	453.97
7183_AS1  USA	Dollar	1234.50	453.97
7183_AS2  USA	Dollar	654.78	325.98
7183_AS2  USA	Dollar	654.78	325.98
&lt;/PRE&gt;
&lt;P&gt;In summary I want all records from 'have2' plus the matching values from 'Expenses' and 'RC' variables from 'have1'. Any guidance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 12:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678066#M204617</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-08-20T12:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Join Condition to get the data from both the tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678067#M204618</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge have2 have1;
   by Segment;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Aug 2020 12:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678067#M204618</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-08-20T12:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Join Condition to get the data from both the tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678068#M204619</link>
      <description>&lt;P&gt;If SQL,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have1;
    input Segment $ Expenses RC;
    datalines;
7183_AS1 1234.50 453.97 
7183_AS2 654.78 325.98 
;
run;

data have2;
    input Segment $ Country $ Currency $;
    datalines;
7183_AS1 USA Dollar
7183_AS1 USA Dollar
7183_AS1 USA Dollar
7183_AS2 USA Dollar
7183_AS2 USA Dollar
;
run;

proc sql;
 create table want as
 select a.*,expenses,rc
 from have2 a left join have1 b
 on a.segment=b.segment;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Aug 2020 12:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678068#M204619</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-20T12:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Join Condition to get the data from both the tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678077#M204620</link>
      <description>&lt;P&gt;What if one of the datasets has no matches? And are the segments unique in have1?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 13:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678077#M204620</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-20T13:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Join Condition to get the data from both the tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678078#M204621</link>
      <description>Right, How to do this with join?&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Aug 2020 13:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Condition-to-get-the-data-from-both-the-tables/m-p/678078#M204621</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-08-20T13:10:05Z</dc:date>
    </item>
  </channel>
</rss>

