<?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: Find Strings matching a certain pattern and remove the exceptions. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675031#M203321</link>
    <description>&lt;P&gt;Thank You for the code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be done without a datastep?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Also not sure if this helps but,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;the string that i am looking for&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;has an underscore&lt;/LI&gt;&lt;LI&gt;begins with &lt;STRONG&gt;&lt;FONT size="6" color="#FF0000"&gt;(&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;and ends with &lt;FONT size="6" color="#FF0000"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;is not in exception list.&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Thu, 06 Aug 2020 15:26:18 GMT</pubDate>
    <dc:creator>david27</dc:creator>
    <dc:date>2020-08-06T15:26:18Z</dc:date>
    <item>
      <title>Find Strings matching a certain pattern and remove the exceptions.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675006#M203307</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let exception=b_n1h1 c_n1h1 f_n1h1 m_n1h1;
%let have=(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + 
(e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2]);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want a list of all values(anything that has an underscore) from 'have' that are NOT in 'exception'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want==n1h2_output n1h1_n1h2 a_n1h1 d_n1h1 e_n1h1 g_n1h1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 14:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675006#M203307</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-06T14:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find Strings matching a certain pattern and remove the exceptions.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675025#M203318</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215179"&gt;@david27&lt;/a&gt;&amp;nbsp; Please see if this works. I just took a quick stab at your string with some easy assumptions-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let exception=b_n1h1 c_n1h1 f_n1h1 m_n1h1;
%let have=(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + 
(e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2]);

data have;
  have="&amp;amp;have";
run;
data want;
 set have;
 array ex(4)$30 _temporary_('b_n1h1' 'c_n1h1' 'f_n1h1' 'm_n1h1');
 do _n_=1 to countw(have,'*');
  w=scan(have,_n_,'*');
  want=scan(w,-1);
  if index(want,'_') and want not in ex then output;
 end;
 drop w;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;have&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;want&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;n1h2_output&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;n1h1_n1h2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;a_n1h1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;d_n1h1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;e_n1h1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + (e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2])&lt;/TD&gt;
&lt;TD class="l data"&gt;g_n1h1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Aug 2020 14:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675025#M203318</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-06T14:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find Strings matching a certain pattern and remove the exceptions.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675031#M203321</link>
      <description>&lt;P&gt;Thank You for the code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be done without a datastep?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Also not sure if this helps but,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;the string that i am looking for&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;has an underscore&lt;/LI&gt;&lt;LI&gt;begins with &lt;STRONG&gt;&lt;FONT size="6" color="#FF0000"&gt;(&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;and ends with &lt;FONT size="6" color="#FF0000"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;is not in exception list.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 06 Aug 2020 15:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675031#M203321</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-06T15:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find Strings matching a certain pattern and remove the exceptions.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675047#M203332</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215179"&gt;@david27&lt;/a&gt;&amp;nbsp; "Without a datastep makes it more a heavier syntax in my opinion-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

 options minoperator mindelimiter=' ';
%macro t;
 %global want;
 %let want=;
 %let exception=b_n1h1 c_n1h1 f_n1h1 m_n1h1;
 %let have=(n1h2_output*((n1h1_n1h2*((a_n1h1*a[i]-b[1]) + (b_n1h1*b[i]-b[1]) + (c_n1h1*c[i]-b[1]) + (d_n1h1*d[i]-b[1]) + 
(e_n1h1*e[i]-b[1]) + (f_n1h1*f[i]-b[1]) + (g_n1h1*g[i]-b[1]))-b[2]);
 %do i=1 %to %sysfunc(countw(%bquote(&amp;amp;have),%str(*)));
  %let w=%scan(%bquote(&amp;amp;have),&amp;amp;i,%str(*));
  %let need=%scan(%bquote(&amp;amp;w),-1);
  %put &amp;amp;=need;
  %if %index(&amp;amp;need,%str(_))&amp;gt;0 and %eval(&amp;amp;need  in (&amp;amp;exception))=0  %then %let want=&amp;amp;want &amp;amp;need;
 %end;
%mend t;
%t

%put &amp;amp;=want;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LOG:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;       %put &amp;amp;=want;
WANT=n1h2_output n1h1_n1h2 a_n1h1 d_n1h1 e_n1h1 g_n1h1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Aug 2020 16:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675047#M203332</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-06T16:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find Strings matching a certain pattern and remove the exceptions.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675495#M203551</link>
      <description>You were correct. Data step is better. Also it’s more flexible.&lt;BR /&gt;Thank You very much.</description>
      <pubDate>Sun, 09 Aug 2020 18:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Strings-matching-a-certain-pattern-and-remove-the/m-p/675495#M203551</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-09T18:44:55Z</dc:date>
    </item>
  </channel>
</rss>

