<?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: consecutive flagging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/516911#M139653</link>
    <description>&lt;P&gt;Can you better explain what you mean when you say&amp;nbsp;&lt;SPAN&gt;i want to count two consecutive 1's and flag that var and then three consecutive 0s and then flag&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the top record?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can't tell from your example what this means.&amp;nbsp; For the first flag do you pick observation 4 because it is the starting observation before 2 consecutive&amp;nbsp;1's?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Likewise, why is flag_0 7 in group 101?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Is this because you don't have 3 consecutive 0's until observation 8, so you want the code to flag observation 8 and then subtract one?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It's a&amp;nbsp; bit confusion because flag_0 is also the 3rd zero in your 101 group as well as your 102 group... So i can't tell if you are simply trying to find the 3rd occurrence&amp;nbsp;of the value 0, or the start of 3 0's in a row based upon your example data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If i'm following you, why does flag_1 not subtract 1&amp;nbsp; but flag_0 subtract one?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Nov 2018 23:34:52 GMT</pubDate>
    <dc:creator>Anotherdream</dc:creator>
    <dc:date>2018-11-28T23:34:52Z</dc:date>
    <item>
      <title>consecutive flagging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/516897#M139648</link>
      <description>&lt;P&gt;data fakedata;&lt;/P&gt;&lt;P&gt;input id var rslt;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;101 1 .&lt;BR /&gt;101 2 0&lt;BR /&gt;101 3 .&lt;BR /&gt;101 4 1&lt;BR /&gt;101 5 1&lt;BR /&gt;101 6 0&lt;BR /&gt;101 7 1&lt;BR /&gt;101 8 0&lt;BR /&gt;101 9 0&lt;BR /&gt;101 10 0&lt;BR /&gt;102 1 .&lt;BR /&gt;102 2 0&lt;BR /&gt;102 3 0&lt;BR /&gt;102 4 1&lt;BR /&gt;102 5 1&lt;BR /&gt;102 6 1&lt;BR /&gt;102 7 0&lt;BR /&gt;102 8 0&lt;BR /&gt;102 9 0&lt;BR /&gt;102 10 0&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to count two consecutive 1's and flag that var and then three consecutive 0s and then flag&lt;BR /&gt;the top record . so lets say we create 2 new variables flag_1 and flag_0&lt;BR /&gt;so for id=101 we will have flag_1=4 and flag_0=7&lt;BR /&gt;id=102 we will have flag_1=4 and flag_0=6&lt;/P&gt;&lt;P&gt;once thats flagged i need to count the missing rslt before flag_1 was identified meaning&lt;BR /&gt;for id=101 we identified flag_1=4 , so before var=4 we have 2 missing records so i need another variable flag_miss_count=2&lt;BR /&gt;for id=101 flag_miss_count=1&lt;BR /&gt;any help appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the resulting data should be like&amp;nbsp;&lt;/P&gt;&lt;P&gt;id var rslt flag_1 flag_0 flag_miss_count&lt;BR /&gt;101 1 .&lt;BR /&gt;101 2 0&lt;BR /&gt;101 3 .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;101 4 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;BR /&gt;101 5 1&lt;BR /&gt;101 6 0&lt;BR /&gt;101 7 1&lt;BR /&gt;101 8 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7&lt;BR /&gt;101 9 0&lt;BR /&gt;101 10 0&lt;BR /&gt;102 1 .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;102 2 0&lt;BR /&gt;102 3 0&lt;BR /&gt;102 4 1&amp;nbsp; &amp;nbsp;4&lt;BR /&gt;102 5 1&lt;BR /&gt;102 6 1&lt;BR /&gt;102 7 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;BR /&gt;102 8 0&lt;BR /&gt;102 9 0&lt;BR /&gt;102 10 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;eric&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 22:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/516897#M139648</guid>
      <dc:creator>eric2</dc:creator>
      <dc:date>2018-11-28T22:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: consecutive flagging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/516911#M139653</link>
      <description>&lt;P&gt;Can you better explain what you mean when you say&amp;nbsp;&lt;SPAN&gt;i want to count two consecutive 1's and flag that var and then three consecutive 0s and then flag&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the top record?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can't tell from your example what this means.&amp;nbsp; For the first flag do you pick observation 4 because it is the starting observation before 2 consecutive&amp;nbsp;1's?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Likewise, why is flag_0 7 in group 101?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Is this because you don't have 3 consecutive 0's until observation 8, so you want the code to flag observation 8 and then subtract one?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It's a&amp;nbsp; bit confusion because flag_0 is also the 3rd zero in your 101 group as well as your 102 group... So i can't tell if you are simply trying to find the 3rd occurrence&amp;nbsp;of the value 0, or the start of 3 0's in a row based upon your example data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If i'm following you, why does flag_1 not subtract 1&amp;nbsp; but flag_0 subtract one?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 23:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/516911#M139653</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2018-11-28T23:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: consecutive flagging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/517074#M139724</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;we can create one variable and capture the result but for easy understanding i created three different variables.&lt;/P&gt;&lt;P&gt;basically first logic we need to count consecutive 1s which occur more than twice within a subject and flag the first record where that started, similarly next logic within the same subject we need to count consecutive 0s which occur more than thrice but for this we need to flag the previous record. so order of checking will be consecutive 1s and then consecutive 0s within same subject&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 15:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/consecutive-flagging/m-p/517074#M139724</guid>
      <dc:creator>eric2</dc:creator>
      <dc:date>2018-11-29T15:18:45Z</dc:date>
    </item>
  </channel>
</rss>

