<?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: Using WHERE in a PROC SQL statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213420#M52642</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a left join, every record from the left table is included in the result, even when the &lt;STRONG&gt;on&lt;/STRONG&gt; condition is not met. Move the condition to a &lt;STRONG&gt;where&lt;/STRONG&gt; clause :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table reenroll_statecourses_teacher as select&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;c.*,r.* from statecourses_teacher as c left join join1 as r &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;on c.studentID=r.studentID and c.crs_schoolid=r.schoolid and (c.dateleft=r.exitdate or c.dateleft=r.exitdate+1)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where &lt;STRONG style="font-family: inherit; font-size: 13px; font-style: inherit;"&gt;c.termid lt 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;order by studentID;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Mar 2015 14:24:48 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-03-31T14:24:48Z</dc:date>
    <item>
      <title>Using WHERE in a PROC SQL statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213419#M52641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table reenroll_statecourses_teacher as select&lt;/P&gt;&lt;P&gt;c.*,r.* from statecourses_teacher as c left join join1 as r&amp;nbsp; &lt;/P&gt;&lt;P&gt;on c.studentID=r.studentID and c.crs_schoolid=r.schoolid &lt;STRONG&gt;and c.termid lt 0&lt;/STRONG&gt; and (c.dateleft=r.exitdate or c.dateleft=r.exitdate+1)&lt;/P&gt;&lt;P&gt;order by studentID;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the part in bold "&lt;STRONG style="font-size: 13.3333330154419px;"&gt;and c.termid lt 0" &lt;/STRONG&gt;is not correct because the matching is not what I'm wanting.&amp;nbsp; I only want observations from the data set "&lt;SPAN style="font-size: 13.3333330154419px;"&gt;statecourses_teacher" WHERE the termid is negative but I get matches where termid is both positive and negative.&amp;nbsp; I checked and termid is a numeric value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate any&amp;nbsp; help.&lt;/P&gt;&lt;P&gt;Gregg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 14:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213419#M52641</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2015-03-31T14:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using WHERE in a PROC SQL statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213420#M52642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a left join, every record from the left table is included in the result, even when the &lt;STRONG&gt;on&lt;/STRONG&gt; condition is not met. Move the condition to a &lt;STRONG&gt;where&lt;/STRONG&gt; clause :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table reenroll_statecourses_teacher as select&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;c.*,r.* from statecourses_teacher as c left join join1 as r &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;on c.studentID=r.studentID and c.crs_schoolid=r.schoolid and (c.dateleft=r.exitdate or c.dateleft=r.exitdate+1)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where &lt;STRONG style="font-family: inherit; font-size: 13px; font-style: inherit;"&gt;c.termid lt 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;order by studentID;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 14:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213420#M52642</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-03-31T14:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using WHERE in a PROC SQL statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213421#M52643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&amp;nbsp; I am getting the expected results now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 14:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-WHERE-in-a-PROC-SQL-statement/m-p/213421#M52643</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2015-03-31T14:30:43Z</dc:date>
    </item>
  </channel>
</rss>

