<?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 Subsetting using &amp;quot;or&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820578#M323899</link>
    <description>&lt;P&gt;How can I create a subset comprised of observations that have certain values for certain variables? My inclination would be to use OR and WHERE statements like this (this syntax doesn't work. It's provided simply to communicate what I'm trying to do):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.rx_meds_2009_2010;
	SET work.rxq_drug;

	where RXDDCI1A = 40;
	or where RXDDCI2A = 40;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My understanding is that the IN operator wouldn't work here because there are multiple variables, not just multiple values. IF statements also didn't seem to solve the problem correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 19:32:34 GMT</pubDate>
    <dc:creator>_maldini_</dc:creator>
    <dc:date>2022-06-27T19:32:34Z</dc:date>
    <item>
      <title>Subsetting using "or"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820578#M323899</link>
      <description>&lt;P&gt;How can I create a subset comprised of observations that have certain values for certain variables? My inclination would be to use OR and WHERE statements like this (this syntax doesn't work. It's provided simply to communicate what I'm trying to do):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.rx_meds_2009_2010;
	SET work.rxq_drug;

	where RXDDCI1A = 40;
	or where RXDDCI2A = 40;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My understanding is that the IN operator wouldn't work here because there are multiple variables, not just multiple values. IF statements also didn't seem to solve the problem correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820578#M323899</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-06-27T19:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting using "or"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820579#M323900</link>
      <description>&lt;P&gt;that code does not look correct. I think you should use&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if RXDDCI1A = 40 or  RXDDCI2A = 40;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820579#M323900</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-27T19:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting using "or"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820580#M323901</link>
      <description>&lt;P&gt;WHICHC/WHICHN functions are also an option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In would work in the opposite fashion, I think:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 40 in (list of variables);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36911"&gt;@_maldini_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How can I create a subset comprised of observations that have certain values for certain variables? My inclination would be to use OR and WHERE statements like this (this syntax doesn't work. It's provided simply to communicate what I'm trying to do):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.rx_meds_2009_2010;
	SET work.rxq_drug;

	where RXDDCI1A = 40;
	or where RXDDCI2A = 40;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My understanding is that the IN operator wouldn't work here because there are multiple variables, not just multiple values. IF statements also didn't seem to solve the problem correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820580#M323901</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-27T19:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting using "or"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820581#M323902</link>
      <description>&lt;P&gt;WHERE is statement. The statement starts with the WHERE keyword and ends with the semicolon after the condition.&lt;/P&gt;
&lt;P&gt;OR is not a data step statement, so it cannot immediately follow a semicolon. If you need more than one condition, you have to combine the conditions in one statement.&lt;/P&gt;
&lt;P&gt;Your&amp;nbsp;&lt;U&gt;single&lt;/U&gt; WHERE statement has to be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where RXDDCI1A = 40 or RXDDCI2A = 40;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820581#M323902</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-27T19:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting using "or"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820657#M323949</link>
      <description>&lt;P&gt;In the special case of &lt;EM&gt;one&lt;/EM&gt; value and several variables the IN operator in conjunction with an array is convenient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id rxddci1-rxddci3 rxddci1a rxddci2a rxddci3a;
cards;
1 10 20 30 40 50 60
2 11 21 31 41 51 61
;

data want;
set have;
array rx[*] rxddci:;
if 40 in rx;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The condition "&lt;FONT face="courier new,courier"&gt;40 in rx&lt;/FONT&gt;" would &lt;EM&gt;not&lt;/EM&gt; work in a WHERE statement and also the array name in the condition &lt;EM&gt;cannot&lt;/EM&gt; be replaced by a variable list of any kind.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 08:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-using-quot-or-quot/m-p/820657#M323949</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-06-28T08:34:48Z</dc:date>
    </item>
  </channel>
</rss>

