<?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: How to do a left join conditioned on the values of a particular variable in the left table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749876#M235747</link>
    <description>&lt;P&gt;I don't think I would write it that way. I would just use the where clause in SQL. If a and b have any of the same columns, SAS is going to put a warning in the log that the column exists in more than one table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
create table AC as 
select a.*,b.*
from ac as a 
left join 
dc as b
on a.key=b.key
where a.month=5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Jun 2021 14:26:35 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2021-06-23T14:26:35Z</dc:date>
    <item>
      <title>How to do a left join conditioned on the values of a particular variable in the left table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749874#M235746</link>
      <description>&lt;P&gt;I have two tables AC and DC, where the 'Account_Number' field is the merging key.&lt;/P&gt;
&lt;P&gt;I want to do a left join on both these tables where table AC is the left table. But I want this join to happen only when the variable 'Month' in table AC takes value=5. But I want to retain all the observations of table AC and the new variables that are coming from table DC to AC will only have values in cases where Month=5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will this way work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE AC AS&lt;BR /&gt;SELECT A.*, B.* FROM AC(where=(month=5)) AS A&lt;BR /&gt;LEFT JOIN&lt;BR /&gt;DC AS B&lt;BR /&gt;ON A.KEY=B.KEY;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 14:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749874#M235746</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-06-23T14:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a left join conditioned on the values of a particular variable in the left table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749876#M235747</link>
      <description>&lt;P&gt;I don't think I would write it that way. I would just use the where clause in SQL. If a and b have any of the same columns, SAS is going to put a warning in the log that the column exists in more than one table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
create table AC as 
select a.*,b.*
from ac as a 
left join 
dc as b
on a.key=b.key
where a.month=5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 14:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749876#M235747</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-23T14:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a left join conditioned on the values of a particular variable in the left table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749881#M235749</link>
      <description>This works. Thanks a lot!</description>
      <pubDate>Wed, 23 Jun 2021 14:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-left-join-conditioned-on-the-values-of-a-particular/m-p/749881#M235749</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-06-23T14:30:53Z</dc:date>
    </item>
  </channel>
</rss>

