<?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 get maximum number of consecutive values? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529581#M5569</link>
    <description>&lt;P&gt;in a hurry to catch the train to go home . i will leave some notes in a while&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2019 23:18:25 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-23T23:18:25Z</dc:date>
    <item>
      <title>How to get maximum number of consecutive values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529530#M5555</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like this:&amp;nbsp;&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 day hw consec; 
	datalines; 
		 1 1 1
		 2 1 2
		 3 1 3
		 4 0 0 
		 5 0 0 
		 6 1 1
		 7 1 2
		 8 0 0 
		 9 1 1
	        10 0 0
		; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new variable (max) that grabs the maximum consecutive count in a sequence. I created the consecutive variable hoping to do this but am having trouble figuring out the next step. Maybe that was not necessary and this can be done with just the hw variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal dataset looks like this:&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 day hw consec max; 
	datalines; 
		 1 1 1 3
		 2 1 2 3
		 3 1 3 3
		 4 0 0 0
		 5 0 0 0
		 6 1 1 2
		 7 1 2 2
		 8 0 0 0
		 9 1 1 1
	        10 0 0 0
		; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529530#M5555</guid>
      <dc:creator>pamplemousse822</dc:creator>
      <dc:date>2019-01-23T20:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum number of consecutive values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529555#M5560</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have; 
	input day hw consec; 
	datalines; 
		 1 1 1
		 2 1 2
		 3 1 3
		 4 0 0 
		 5 0 0 
		 6 1 1
		 7 1 2
		 8 0 0 
		 9 1 1
	        10 0 0
		; 
run; 
data want;
if 0 then set have;
do max=1 by 1 until(last.hw);
set have;
by hw notsorted;
end;
do until(last.hw);
set have;
by hw notsorted;
max=max*(hw=1);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2019 21:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529555#M5560</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-23T21:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum number of consecutive values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529580#M5568</link>
      <description>&lt;P&gt;This is perfect! Thank you very much. Can you please explain briefly how this works?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 23:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529580#M5568</guid>
      <dc:creator>pamplemousse822</dc:creator>
      <dc:date>2019-01-23T23:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum number of consecutive values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529581#M5569</link>
      <description>&lt;P&gt;in a hurry to catch the train to go home . i will leave some notes in a while&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 23:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529581#M5569</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-23T23:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum number of consecutive values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529720#M5589</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/54903"&gt;@pamplemousse822&lt;/a&gt;&amp;nbsp; Sorry for the delay. Here you go,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Hw is binomial event or in other words occurring as 1 or 0 aka True or False&lt;/P&gt;
&lt;P&gt;2. The need for us is the count of continuous occurrences of true events&lt;/P&gt;
&lt;P&gt;3. The data is very clear and simple in that sense, we can spot the sets of&amp;nbsp;continuous occurrences of true events.&lt;/P&gt;
&lt;P&gt;4. Logic is ---&amp;gt; Loop through the occurrences and count the sets of&amp;nbsp;continuous occurrences of true events. Reset the false(untrue events) to zero.&lt;/P&gt;
&lt;P&gt;5. First loop does the count determining the max as the stated objective and 2nd loop does resetting of untrue events&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Overall, Boolean's, binomial stuff are my specialties. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-get-maximum-number-of-consecutive-values/m-p/529720#M5589</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-24T15:50:15Z</dc:date>
    </item>
  </channel>
</rss>

