<?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 only the underscore values and without any special characters using WHERE caluse in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606388#M176080</link>
    <description>&lt;P&gt;Change GE by GT.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2019 06:23:26 GMT</pubDate>
    <dc:creator>KachiM</dc:creator>
    <dc:date>2019-11-22T06:23:26Z</dc:date>
    <item>
      <title>Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606380#M176076</link>
      <description>&lt;P&gt;I'm using the code below to filter only the underscore values and without any special characters using WHERE caluse, But with the following code I'm not getting the desired output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input TBL $20.;
datalines;
(INS_CON_GRP)
INS_GRT
INS
H_EAL_YE_A
INS_CON_GROUP_DETL
;

data want;
   set have;
   where countc(TBL, '_') ge 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Desired Output is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;H_EAL_YE_A&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;INS_CON_GROUP_DETL&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 05:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606380#M176076</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-22T05:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606388#M176080</link>
      <description>&lt;P&gt;Change GE by GT.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 06:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606388#M176080</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-11-22T06:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606390#M176082</link>
      <description>&lt;P&gt;No, it is not resolving the issue if I change the example data. I ran the code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input TBL $20.;
datalines;
(INS_CON_GRP)
INS_GRT
INS_GR_T
INS
H_EAL_YE_A
(INS_CON_GROUP_DETL)
;

data want;
   set have;
   where countc(TBL, '_') gt 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output which&amp;nbsp;I got is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;H_EAL_YE_A&lt;BR /&gt;(INS_CON_GROUP_DETL)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired Output is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;H_EAL_YE_A&lt;/P&gt;
&lt;P&gt;INS_GR_T&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 06:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606390#M176082</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-22T06:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606391#M176083</link>
      <description>&lt;P&gt;You test for 2 or more underscores, but you didn't create a where condition to apply "without any special characters".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say&amp;nbsp; special characters are anything except letters, numbers, or underscores. Then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input TBL $20.;
datalines;
INS_GRT
INS
H_EAL_YE_A
INS_CON_GROUP_DETL
;

data want;
   set have;
   where countc(TBL, '_') ge 2  and findc(trim(TBL),' ','ADFK')=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FINDC function is the interesting element&amp;nbsp; here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It ordinarily searches the first argument,&amp;nbsp; trim(TBL), for any character in the second argument and returns the position of the first qualifying character in TBL.&amp;nbsp; If none is found it returns a zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When the 2nd argument is blank it is ignored&lt;/LI&gt;
&lt;LI&gt;The third argument has modifiers
&lt;OL&gt;
&lt;LI&gt;A&amp;nbsp; - search for any letter&lt;/LI&gt;
&lt;LI&gt;D - search for any digit&lt;/LI&gt;
&lt;LI&gt;F - search for any underscore&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;But&amp;nbsp; what is wanted is not the position of the first letter, digit, or underscore, but the position of the first character that is NOT one of those.&amp;nbsp; That is done by use of the K in the third argument.&amp;nbsp; So it finds the position of the first non-letter, non-digit, non-underscore.&amp;nbsp; If the function returns a zero there are no special characters.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited additional note: &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; contributed an even simpler solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   where countc(TBL, '_') ge 2  and notname(strip(TBL))=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The NOTNAME function&amp;nbsp; detects any character not eligible for a version 7 sas variable name, i.e. not a letter, number, or underscore.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 05:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606391#M176083</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-24T05:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606392#M176084</link>
      <description>&lt;P&gt;Excellent!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 06:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606392#M176084</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-22T06:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606421#M176099</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input TBL $20.;
datalines;
INS_GRT
INS
H_EAL_YE_A
INS_CON_GROUP_DETL
;

data want;
   set have;
   where countc(TBL, '_') ge 2  and notname(strip(TBL))=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 11:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606421#M176099</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-11-22T11:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only the underscore values and without any special characters using WHERE caluse</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606547#M176142</link>
      <description>"notname" function.  I knew somewhere in the vast array of functions, there was something having to do with varname-eligible characters.  Nice.</description>
      <pubDate>Fri, 22 Nov 2019 19:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-only-the-underscore-values-and-without-any-special/m-p/606547#M176142</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-22T19:00:44Z</dc:date>
    </item>
  </channel>
</rss>

