<?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: Filter multiple columns with the same criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912990#M359869</link>
    <description>&lt;P&gt;Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;! I appreciate your prompt responses. Both of those are good approaches--wish I could accept both as solutions. For my use case, 'T' = col1 = col2... will be easier to maintain, so I'll go with that.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2024 15:27:24 GMT</pubDate>
    <dc:creator>mklangley</dc:creator>
    <dc:date>2024-01-25T15:27:24Z</dc:date>
    <item>
      <title>Filter multiple columns with the same criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912905#M359836</link>
      <description>&lt;P&gt;Suppose I have data like the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input col1 $ col2 $ col_with_diff_naming_convention $ col4 $ col5 $;
    datalines;
T  F  T  W  O
T  T  T  T  T
W  E  T  H  T
P  T  H  J  T
T  G  T  H  L
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to &lt;EM&gt;omit&lt;/EM&gt; all rows where the columns &lt;EM&gt;all&amp;nbsp;&lt;/EM&gt;equal "T". In the example above, I want all rows except row 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could do this with hard-coding (like below) or using DICTIONARY.COLUMNS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where col1 ne 'T'
        and col2 ne 'T'
        and col_with_diff_naming_convention ne 'T'
        and col4 ne 'T'
        and col5 ne 'T';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I am wondering if anybody knows a slick way to do this using arrays (or another similarly concise approach).&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 22:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912905#M359836</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2024-01-24T22:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Filter multiple columns with the same criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912907#M359837</link>
      <description>&lt;P&gt;This works for your example data and is likely extensible to more "real" data like words instead of single letter values:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   if not ('T' =  col1 = col2 = col_with_diff_naming_convention = col4 = col5 );
run;&lt;/PRE&gt;
&lt;P&gt;SAS will allow multiple comparisons such as =, &amp;lt; , &amp;gt; all in one expression though &amp;lt; and &amp;gt; and similar are generally not a good idea for character values until you really understand how they work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is actually single character then you could concatenate all the variables into one and use the COUNTC function to see how many times T appears and if it matches the number of variables then delete the observation.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 22:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912907#M359837</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-24T22:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Filter multiple columns with the same criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912912#M359838</link>
      <description>&lt;P&gt;This works for your example but something more flexible may be preferable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if cats(of _character_) ne 'TTTTT';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jan 2024 00:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912912#M359838</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-01-25T00:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filter multiple columns with the same criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912990#M359869</link>
      <description>&lt;P&gt;Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;! I appreciate your prompt responses. Both of those are good approaches--wish I could accept both as solutions. For my use case, 'T' = col1 = col2... will be easier to maintain, so I'll go with that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 15:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912990#M359869</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2024-01-25T15:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Filter multiple columns with the same criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912996#M359871</link>
      <description>&lt;P&gt;You may need to consider case for such comparisons and require use of either UPCASE or LOWCASE functions on all of your variables for the comparison as "ABC" is not equal to "abc" "Abc" "aBc" (etc.).&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 15:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-multiple-columns-with-the-same-criteria/m-p/912996#M359871</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-25T15:32:10Z</dc:date>
    </item>
  </channel>
</rss>

