<?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 left join on two variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825484#M326066</link>
    <description>&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
  create table data3 as  &lt;BR /&gt;  select * 
  from data1 as a &lt;BR /&gt; left join data2 as b 
  on a.subject = b.subject and a.date=b.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Separate your conditions with an AND&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 17:59:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-07-26T17:59:03Z</dc:date>
    <item>
      <title>how to left join on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825483#M326065</link>
      <description>&lt;P&gt;I want to do a left join on 2 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my code but there's an error because of the "on" statement "&lt;CODE class=""&gt;on a.subject, a.date = b.subject, b.date;&lt;/CODE&gt;"&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
  create table data3 as  select * 
  from data1 as a left join data2 as b 
  on a.subject, a.date = b.subject, b.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 17:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825483#M326065</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2022-07-26T17:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to left join on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825484#M326066</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
  create table data3 as  &lt;BR /&gt;  select * 
  from data1 as a &lt;BR /&gt; left join data2 as b 
  on a.subject = b.subject and a.date=b.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Separate your conditions with an AND&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 17:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825484#M326066</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-26T17:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to left join on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825485#M326067</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table data3 as  select * 
  from data1 as a left join data2 as b 
  on a.subject = b.subject and a.date = b.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 17:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825485#M326067</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-26T17:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to left join on two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825570#M326082</link>
      <description>&lt;P&gt;Hint: when you get errors then include the code with the errors, the entire procedure, data step or macro, with all the messages.&lt;/P&gt;
&lt;P&gt;In your case the error would have looked like this:&lt;/P&gt;
&lt;PRE&gt;765  proc sql;
766    create table data3 as  select *
767    from sashelp.class as a left join sashelp.class as b
768    on a.sex, a.age = b.sex, b.age;
                       -
                       22
                       76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, ',', ANSIMISS, AS,
              CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS,
              ORDER, OUTER, RIGHT, UNION, WHERE.

ERROR 76-322: Syntax error, statement will be ignored.
&lt;/PRE&gt;
&lt;P&gt;The presence of all the join options tells us that the error is that where the = in your code appears than SAS is expecting something related to another join. The comma was interpreted as a Cartesian join instruction similar to&lt;/P&gt;
&lt;PRE&gt;proc sql;
   select a.*,b.*
   from someset as a, otherset as b
  ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 22:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-left-join-on-two-variables/m-p/825570#M326082</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-26T22:37:57Z</dc:date>
    </item>
  </channel>
</rss>

