<?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: Why my left join does not work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571992#M161392</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us some example data, the results you obtain and those you want. A log extract can also help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code, you wrote &lt;FONT size="3" face="Courier New"&gt;b*ratecde&lt;/FONT&gt; instead of &lt;FONT size="3" face="Courier New"&gt;b.ratecde.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jul 2019 10:13:14 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2019-07-09T10:13:14Z</dc:date>
    <item>
      <title>Why my left join does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571987#M161389</link>
      <description>&lt;P&gt;Hi all, facing problem regarding the left join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the ratecde column from &lt;FONT face="Courier New" size="3"&gt;&lt;FONT color="#ff9900" face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;pl201903.Fire_clm_cov_201903&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT face="arial,helvetica,sans-serif"&gt;added into the table &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;pl201903.Fire_clm_201903.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;When the new column is added, both claim datas from two table sources must be the same.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;and also the zsumsi data from &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;pl201903.Fire_clm_201903 &lt;/FONT&gt;&lt;/STRONG&gt;must be the same as the totsi from the second one &lt;FONT color="#ff9900" face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;pl201903.Fire_clm_cov_201903&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code below, However, this does not work. I don't know where is it wrong. It will automatically help me add on some rows which is repeat from the existing rows from original file.&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;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; pl201903.query &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt; &lt;FONT color="#008080" face="Courier New" size="3"&gt;a.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*,b.ratecde as ratecde_1&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; pl201903.Fire_clm_201903 a &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;left&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;join &lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;pl201903.Fire_clm_cov_201903 b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.claim=b.claim &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.zsumsi=b.totsi;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 10:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571987#M161389</guid>
      <dc:creator>Kayla_Tan222</dc:creator>
      <dc:date>2019-07-09T10:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why my left join does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571989#M161390</link>
      <description>&lt;P&gt;Hello It seems that the reference to your second table is incorrect. Also the Left join syntax is incorrect. Please see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; &amp;nbsp; create&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pl201903.query&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; &amp;nbsp; select&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; b.ratecde AS ratecde_1&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pl201903.Fire_clm_201903 a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;join&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;pl201903.Fire_clm_cov_201903 b&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; &amp;nbsp; on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a.claim=b.claim&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a.zsumsi=b.totsi&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp; &amp;nbsp; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;QUIT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 10:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571989#M161390</guid>
      <dc:creator>euro_andres</dc:creator>
      <dc:date>2019-07-09T10:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why my left join does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571992#M161392</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us some example data, the results you obtain and those you want. A log extract can also help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code, you wrote &lt;FONT size="3" face="Courier New"&gt;b*ratecde&lt;/FONT&gt; instead of &lt;FONT size="3" face="Courier New"&gt;b.ratecde.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 10:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/571992#M161392</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-07-09T10:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why my left join does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/572022#M161403</link>
      <description>&lt;P&gt;It is not at all clear what your issue is.&lt;/P&gt;
&lt;P&gt;Perhaps the issue is that your B table has repeating observations?&lt;/P&gt;
&lt;P&gt;So if LEFT has one observation of a particular key combination but RIGHT has 10 observations for that same key combination the result of your left join will have 10 observations for that key combination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to figure out a way to make the right side have just one observation.&amp;nbsp; This might work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table pl201903.query as
  select a.*,b.ratecde as ratecde_1 
  from pl201903.Fire_clm_201903 a 
  left join (select distinct claim,totsi,ratecde from pl201903.Fire_clm_cov_201903) b
    on a.claim=b.claim and a.zsumsi=b.totsi
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But you might need to use some method to pick one of many different RATECDE values.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-my-left-join-does-not-work/m-p/572022#M161403</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-09T12:47:41Z</dc:date>
    </item>
  </channel>
</rss>

