<?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: Proc SQL Left Join Based on a Condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Left-Join-Based-on-a-Condition/m-p/939236#M368811</link>
    <description>&lt;P&gt;Sounds like you want the COALESCE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.state
     , a.city
     , coalesce(a.coeff,b.coeff) as coeff
from a 
left join b
on a.state=b.state and a.city=b.city
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Aug 2024 13:36:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-08-14T13:36:37Z</dc:date>
    <item>
      <title>Proc SQL Left Join Based on a Condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Left-Join-Based-on-a-Condition/m-p/939232#M368810</link>
      <description>&lt;P&gt;I have one dataset which is missing some coefficient data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a separate dataset with a similar structure which contains much of the missing data, but when I left join them, I don't want it replacing the rows with existing coefficients. I only want the 2nd dataset's numbers to fill in the blank rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying out conditional proc SQL's, but nothing has worked so far. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset1&lt;/P&gt;&lt;P&gt;State&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; City/Town&amp;nbsp; &amp;nbsp; &amp;nbsp; Coefficient&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ALABAMA&lt;/TD&gt;&lt;TD&gt;AUTAUGA&lt;/TD&gt;&lt;TD&gt;1.01473&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALABAMA&lt;/TD&gt;&lt;TD&gt;BALDWIN&lt;/TD&gt;&lt;TD&gt;19.33969&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALABAMA&lt;/TD&gt;&lt;TD&gt;BARBOUR&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 13:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Left-Join-Based-on-a-Condition/m-p/939232#M368810</guid>
      <dc:creator>E_W</dc:creator>
      <dc:date>2024-08-14T13:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Left Join Based on a Condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Left-Join-Based-on-a-Condition/m-p/939236#M368811</link>
      <description>&lt;P&gt;Sounds like you want the COALESCE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.state
     , a.city
     , coalesce(a.coeff,b.coeff) as coeff
from a 
left join b
on a.state=b.state and a.city=b.city
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Aug 2024 13:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Left-Join-Based-on-a-Condition/m-p/939236#M368811</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-14T13:36:37Z</dc:date>
    </item>
  </channel>
</rss>

