<?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: Use of WHERE and OR in the same proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635794#M78087</link>
    <description>&lt;P&gt;You have told us what doesn't work, but we don't know what output you do want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us a small data set as an example, with the desired output?&lt;/P&gt;</description>
    <pubDate>Mon, 30 Mar 2020 12:31:36 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-03-30T12:31:36Z</dc:date>
    <item>
      <title>Use of WHERE and OR in the same proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635793#M78086</link>
      <description>&lt;P&gt;Hello Community -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an extremely simple coding question, which I am stuck at:&lt;/P&gt;&lt;P&gt;My current code is (which resulted in an abort to the teradata due to size limitation):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE Short_Table&amp;nbsp;AS&lt;BR /&gt;SELECT DISTINCT *&lt;/P&gt;&lt;P&gt;From All_Data&lt;/P&gt;&lt;P&gt;where variable1 = 123&lt;/P&gt;&lt;P&gt;and variable2 = 'xyz' or variable3 = 'abc' /*cause of the error, because it pulls all the data*/&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried this version:&lt;/P&gt;&lt;P&gt;and (variable2 = 'xyz' or variable3 = 'abc') /* the results&amp;nbsp;did not include the variable3 condition*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in&amp;nbsp; advance!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 12:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635793#M78086</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2020-03-30T12:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Use of WHERE and OR in the same proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635794#M78087</link>
      <description>&lt;P&gt;You have told us what doesn't work, but we don't know what output you do want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us a small data set as an example, with the desired output?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 12:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635794#M78087</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-30T12:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Use of WHERE and OR in the same proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635795#M78088</link>
      <description>&lt;P&gt;First:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where variable1 = 123 and variable2 = 'xyz' or variable3 = 'abc' &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is equivalent to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where (variable1 = 123 and variable2 = 'xyz') or variable3 = 'abc' &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as "and" is evaluated before "or".&lt;/P&gt;
&lt;P&gt;So your try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where variable1 = 123 and (variable2 = 'xyz' or variable3 = 'abc') &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is correct, but depends on the actual contents of variable3. Spelling, uppercase/lowercase, leading blanks can all cause your condition to never be true.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 12:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635795#M78088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-30T12:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use of WHERE and OR in the same proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635846#M78091</link>
      <description>&lt;P&gt;Since you say you had an error that "pulls all the data" then you might want to share some of the value incorrectly pulled and explain why those are incorrect. The values would only have to be from your variables 1 , 2 and 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However these may need to be actual values and not your moderately obvious dummy values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 15:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-of-WHERE-and-OR-in-the-same-proc-SQL/m-p/635846#M78091</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-30T15:25:44Z</dc:date>
    </item>
  </channel>
</rss>

