<?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 sustr statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400302#M97047</link>
    <description>&lt;P&gt;If you're just checking for the start of the string to match consider using the : operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x(i)  in: ('12345', '23456');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the length of your X variable can be smaller than the string this likely won't work though.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Oct 2017 15:15:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-02T15:15:43Z</dc:date>
    <item>
      <title>multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400273#M97032</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have multiple subst&amp;nbsp;statements and I want to run them all at once. Can some one help on the best way to combine all these statements in once (I have 30+ statements)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a (drop=i); set b; array {x} dx:; ar=1=0;&lt;/P&gt;&lt;P&gt;do i=1 to dim(x); if substrn(x{i}, 1, 5) in ('12345', '23456', '30987')&lt;/P&gt;&lt;P&gt;then do; ar=1;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a (drop=i); set b; array {x} dx:; arf=1=0;&lt;/P&gt;&lt;P&gt;do i=1 to dim(x); if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;substrn(x{i}, 1, 4) in ('1234', '2432', '3987')&lt;/P&gt;&lt;P&gt;then do; arf=1;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a (drop=i); set b; array {x} dx:; ad=1=0;&lt;/P&gt;&lt;P&gt;do i=1 to dim(x); if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;substrn(x{i}, 1, 2) in ('12', '24', '39')&lt;/P&gt;&lt;P&gt;then do; ad=1;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400273#M97032</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2017-10-02T14:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400281#M97035</link>
      <description>&lt;P&gt;Since the purpose seems to be to just create the flag variables, you can do all the if's in one do loop and omit the leave statement.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400281#M97035</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-02T14:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400292#M97041</link>
      <description>&lt;P&gt;Your code is very hard to read.&amp;nbsp; What are you trying to do, if its just finding those strings, and setting a flag why not:&lt;/P&gt;
&lt;PRE&gt;data a (drop=i);
  set b; 
  array a dx:;
  ar=0;
  arf=0;
  do i=1 to dim(x); 
    ar=ifn(substrn(x{i}, 1, 5) in ('12345', '23456', '30987'),1,ar);
    arf=ifn(substrn(x{i},1,4) in ('1234','2432','3987'),1,arf);
  end;
run; &lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400292#M97041</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-02T14:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400294#M97042</link>
      <description>&lt;P&gt;Thank you for the reply, I am getting an error (one unclosed loop block), would you mind to show me how would you combine them? Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 15:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400294#M97042</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2017-10-02T15:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400300#M97046</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 15:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400300#M97046</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2017-10-02T15:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: multiple sustr statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400302#M97047</link>
      <description>&lt;P&gt;If you're just checking for the start of the string to match consider using the : operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x(i)  in: ('12345', '23456');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the length of your X variable can be smaller than the string this likely won't work though.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 15:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-sustr-statements/m-p/400302#M97047</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-02T15:15:43Z</dc:date>
    </item>
  </channel>
</rss>

