<?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: How to find the length of the longest substring not containing 0 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246069#M17473</link>
    <description>This is what I needed. Thanks a lot! Case closed.</description>
    <pubDate>Tue, 26 Jan 2016 09:48:20 GMT</pubDate>
    <dc:creator>ak2</dc:creator>
    <dc:date>2016-01-26T09:48:20Z</dc:date>
    <item>
      <title>How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246062#M17468</link>
      <description>&lt;P&gt;Hi! I have a string something like&amp;nbsp;this: "1234000111123012001210", i.e. it consists of random natural numbers between 0 and 9 and max lenght is 24. I need to find out how long the longest substring not containing 0 is. In this example the answer&amp;nbsp;is 6 because the substring "111123" is the longest one not containing a 0. How can I do this? I was thinking of putting my string in an array and then loop thru it and count the characters until a 0 occurs, keep the value and compare it against the next substring not containing 0. My thoughts in code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;str='&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1234000111123012001210&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;';&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;array&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; b[&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;24&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;] $;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; dim(b);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;b[i]=substr(str,i,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;count=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;/*the counter used to find the longest substring*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; dim(b);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; b[i]&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; count=count+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;; /*this should caputre 1234 and count=4*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;/*keep the value 4 and do not count the preceding three 0*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;/*then go back to counting the substring '111123'.count=6. compare this count with count=4. keep count=6&amp;nbsp;*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;I am stuck and would appreciate it if anyone can provide me with some help.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246062#M17468</guid>
      <dc:creator>ak2</dc:creator>
      <dc:date>2016-01-26T09:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246063#M17469</link>
      <description>&lt;P&gt;You need two count variables, one that you increment continuously, and one that holds the current maximum count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another totally different two-step approach would be to first generate a new observation&amp;nbsp;for each substring. Then you could&amp;nbsp;do a subsequent SQL using max(length()) construct.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246063#M17469</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-01-26T09:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246066#M17470</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
str='1234000111123012001210';
do i=1 to countw(str,'0');
 max=max(max,length(scan(str,i,'0')));
end;
putlog "max:" max;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246066#M17470</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-26T09:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246067#M17471</link>
      <description>&lt;P&gt;Simply split the string by "0", and count length each time retaining a maximum:&lt;/P&gt;
&lt;PRE&gt;data want (drop=i);
  str="1234000111123012001210";
  i=1;
  max_len=0;
  do while(scan(str,i,"0") ne "");
    max_len=max(lengthn(scan(str,i,"0")),max_len); 
    i=i+1;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246067#M17471</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-26T09:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246068#M17472</link>
      <description>&lt;P&gt;This was exactly what I needed! Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246068#M17472</guid>
      <dc:creator>ak2</dc:creator>
      <dc:date>2016-01-26T09:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246069#M17473</link>
      <description>This is what I needed. Thanks a lot! Case closed.</description>
      <pubDate>Tue, 26 Jan 2016 09:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246069#M17473</guid>
      <dc:creator>ak2</dc:creator>
      <dc:date>2016-01-26T09:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the length of the longest substring not containing 0</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246074#M17474</link>
      <description>&lt;P&gt;Please mark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;'s post as the answer.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 10:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-length-of-the-longest-substring-not-containing-0/m-p/246074#M17474</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-26T10:18:21Z</dc:date>
    </item>
  </channel>
</rss>

