<?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: Multiple variables in a comparison operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562967#M157776</link>
    <description>Thanks! WHICHC() works perfectly for this.</description>
    <pubDate>Fri, 31 May 2019 19:06:23 GMT</pubDate>
    <dc:creator>gekco</dc:creator>
    <dc:date>2019-05-31T19:06:23Z</dc:date>
    <item>
      <title>Multiple variables in a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562694#M157644</link>
      <description>&lt;P&gt;I would like to subset my dataset to include only records where one or more of a set of variable meet a certain value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code looks like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.test2&lt;/P&gt;&lt;P&gt;data work.test&lt;/P&gt;&lt;P&gt;if VAR1 | VAR 2 | VAR3 ... | VAR 30 = 'VALUE';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I condense that to either VAR1-VAR30 = ' VALUE' or VARn = 'VALUE'? Using (keep=VAR1-VAR30) does not seem applicable in this case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 19:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562694#M157644</guid>
      <dc:creator>gekco</dc:creator>
      <dc:date>2019-05-30T19:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple variables in a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562703#M157649</link>
      <description>&lt;P&gt;Your posted code might be valid syntax, but it does not do what you claim to want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is special syntax for using IN with an array that could help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.test2 ;
  set data work.test;
  array vars var1-var30;
  if 'VALUE' in vars ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could use the WHICHC() function. That will actually return which variable number was the first one found to have the value. You don't need an ARRAY for that. A value of 0 (which SAS will treat as FALSE when evaluating as boolean) will indicate that is was not found.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.test2 ;
  set data work.test;
  if whichc('VALUE',of var1-var30);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 20:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562703#M157649</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-30T20:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple variables in a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562967#M157776</link>
      <description>Thanks! WHICHC() works perfectly for this.</description>
      <pubDate>Fri, 31 May 2019 19:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-variables-in-a-comparison-operator/m-p/562967#M157776</guid>
      <dc:creator>gekco</dc:creator>
      <dc:date>2019-05-31T19:06:23Z</dc:date>
    </item>
  </channel>
</rss>

