<?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: Identifying consecutive values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706468#M26366</link>
    <description>Consecutive months I assume? Or two consecutive days? All the days are 15 so I can't imagine that's correct but then all months there are consecutive so then everything shown would meet your criteria somehow?</description>
    <pubDate>Wed, 16 Dec 2020 22:00:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-12-16T22:00:30Z</dc:date>
    <item>
      <title>Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706458#M26363</link>
      <description>&lt;P&gt;From the data below I am trying to find IDs with 2 consecutive date below 80 visits. How Do I go about doing My analysis? Thanks&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Date&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Visit&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;70&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;60&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;120&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;87&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;40&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 16 Dec 2020 21:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706458#M26363</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-16T21:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706462#M26364</link>
      <description>&lt;P&gt;Please show what you expect the result to look like for your given data.&lt;/P&gt;
&lt;P&gt;Is the result a list of just ID like R45 and R30? The records with the values below 80 that qualify? A flag added to your existing data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may have to define exactly what "consecutive" means as well. You show apparent once a month records. Would the records still be considered consecutive if the date is more than one month apart? 3 months? Some other upper limit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other results could respond to the requirement as well.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 21:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706462#M26364</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-16T21:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706467#M26365</link>
      <description>For example, I was a table with records of values below 80 that qualify. By Consecutive meaning the visit date has to be below 80 back to back . If the visit goes &amp;lt; 80 on 5/15/19 and goes &amp;gt; 80 on 6/15/19 and goes &amp;lt; 80 7/15/19 then that is not considered &lt;BR /&gt; 2 consecutive date for this analysis.</description>
      <pubDate>Wed, 16 Dec 2020 21:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706467#M26365</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-16T21:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706468#M26366</link>
      <description>Consecutive months I assume? Or two consecutive days? All the days are 15 so I can't imagine that's correct but then all months there are consecutive so then everything shown would meet your criteria somehow?</description>
      <pubDate>Wed, 16 Dec 2020 22:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706468#M26366</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-16T22:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706473#M26367</link>
      <description>the table I have here is actually an example I just created. but, in the really data some of the visit are like after 2 month, 5 month  8 month and so on..... But, Yes, I meant to say two consecutive days.</description>
      <pubDate>Wed, 16 Dec 2020 22:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706473#M26367</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-16T22:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706474#M26368</link>
      <description>&lt;P&gt;I suggest again that you provide an example of what the output should look like.&lt;/P&gt;
&lt;P&gt;And if you mean consecutive DAYS, then provide data that appears to be such, at least sometimes.&lt;/P&gt;
&lt;P&gt;Include examples of ID where there are no records that qualify and some that do.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 22:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706474#M26368</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-16T22:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706475#M26369</link>
      <description>Please take this table below instead. &lt;BR /&gt;&lt;BR /&gt;ID	Date	Visit &lt;BR /&gt;R45	3/15/19	90&lt;BR /&gt;R45	5/1/19	100&lt;BR /&gt;R45	9/10/19	70&lt;BR /&gt;R45	10/8/19	60&lt;BR /&gt;R90	8/5/19	90&lt;BR /&gt;R90	4/15/19	100&lt;BR /&gt;R90	6/9/19	120&lt;BR /&gt;R90	1/5/20	100&lt;BR /&gt;R30	3/9/19	90&lt;BR /&gt;R30	4/5/19	87&lt;BR /&gt;R30	9/7/19	50&lt;BR /&gt;R30	8/18/20	40</description>
      <pubDate>Wed, 16 Dec 2020 22:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706475#M26369</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-16T22:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706477#M26370</link>
      <description>I want the output that look like this &lt;BR /&gt;R45  9/10/19 70&lt;BR /&gt;R45 10/8/19  60&lt;BR /&gt;R30  9/7/19   50&lt;BR /&gt;R30  8/18/20 40&lt;BR /&gt;continues ..............................&lt;BR /&gt;............................&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Dec 2020 22:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706477#M26370</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-16T22:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706506#M26371</link>
      <description>Under what logic? None of those dates are consecutive at all...</description>
      <pubDate>Thu, 17 Dec 2020 01:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706506#M26371</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T01:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706706#M26384</link>
      <description>&lt;P&gt;Sorry if I am not making this clear, but what I am trying to create a table with the list of (ID, date, visit) where the visit was &amp;lt; 80 back to back.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 16:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706706#M26384</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-17T16:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706806#M26389</link>
      <description>Can someone be able to help me on this question?</description>
      <pubDate>Thu, 17 Dec 2020 21:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706806#M26389</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-17T21:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706883#M26395</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I want the output that look like this &lt;BR /&gt;R45 9/10/19 70&lt;BR /&gt;R45 10/8/19 60&lt;BR /&gt;R30 9/7/19 50&lt;BR /&gt;R30 8/18/20 40&lt;BR /&gt;continues ..............................&lt;BR /&gt;............................&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you want the observations having Visit &amp;lt; 80?&lt;/P&gt;
&lt;P&gt;EDIT: If not, please explain for each observation listed why do you expect it in the result.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 05:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706883#M26395</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-12-18T05:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706894#M26402</link>
      <description>&lt;P&gt;You have a Maxim 42 issue.&lt;/P&gt;
&lt;P&gt;Let me rephrase your question:&lt;/P&gt;
&lt;P&gt;In a dataset that is grouped by ID and ordered (within the group) by DATE, you want to keep those observations where there are two or more consecutive values of VISIT smaller than 80. The dates can have gaps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that correct?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 07:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/706894#M26402</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-18T07:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707020#M26434</link>
      <description>No, I don't want all observations that are visit &amp;lt;80. I will change the variable "visit" to "outcome" variable &lt;BR /&gt;I only want the records that have 2 consecutive (back to back 2x) outcome &amp;lt;80. &lt;BR /&gt;For example, If the first outcome was &amp;lt;80 and 2nd outcome &amp;gt;80 and 3rd outcome &amp;lt;80 then this isnot significant. &lt;BR /&gt;I want the outcome table to have the (ID, date, and the outcome) variables so that, I would now what the ID is and on what dates and what the outcomes where.&lt;BR /&gt;&lt;BR /&gt;Please Help me on this. Thanks!</description>
      <pubDate>Fri, 18 Dec 2020 17:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707020#M26434</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-18T17:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707048#M26439</link>
      <description>correct. but, only 2 consecutive values of VISIT smaller than 80.</description>
      <pubDate>Fri, 18 Dec 2020 19:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707048#M26439</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-18T19:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707051#M26440</link>
      <description>By Consecutive meaning the visit date has to be below 80 back to back only (2x) . For example,  If the visit goes &amp;lt; 80 on 5/15/19 and goes &amp;gt; 80 on 6/15/19 and goes &amp;lt; 80 7/15/19 then that will not be considered 2 consecutive date for this analysis.</description>
      <pubDate>Fri, 18 Dec 2020 19:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707051#M26440</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-18T19:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707055#M26441</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;correct. but, only 2 consecutive values of VISIT smaller than 80.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So 3 or more consecutive values smaller than 80 need to be discarded?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 19:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707055#M26441</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-18T19:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707073#M26443</link>
      <description>yes, that is correct</description>
      <pubDate>Fri, 18 Dec 2020 20:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707073#M26443</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-18T20:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707124#M26449</link>
      <description>&lt;P&gt;So much of this thread has been spent just trying to clarify what the task statement actually should be:&amp;nbsp; "consecutive dates" vs "consecutive records",&amp;nbsp; &amp;nbsp; two&amp;nbsp; less than 80, but not more than two.&amp;nbsp; I've had to read a lot of answers to respondent questions to finally understand what the objective is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your best option is to create an intermediate dataset with a dummy variable (_UNDER80=1 if visit&amp;lt;80).&amp;nbsp; Then read that data set with a BY ID _UNDER80 NOTSORTED to count record-groups and output groups of size 2 if _UNDER80=1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID :$3.	Date :mmddyy.	Visit ;
  format date date9.;
datalines;
R45 3/15/19  90
R45 4/15/19 100
R45 5/15/19  70
R45 6/15/19  60
R90 3/15/19  90
R90 4/15/19 100
R90 5/15/19 120
R90 6/15/19 100
R30 3/15/19  90
R30 4/15/19  87
R30 5/15/19  50
R30 6/15/19  40
run;

data need;
  set have;
  _under80=(visit&amp;lt;80);
run;

data want (drop=_:);
  do _count=1 by 1 until (last._under80);
    set need;
    by id _under80 notsorted;
  end;
  do until (last._under80);
    set need;
    by id _under80 notsorted;
    if _count=2 and _under80=1 then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited addition:&lt;/P&gt;
&lt;P&gt;There is a way to do this in a single step - i.e. avoiding the DATA NEED step.&amp;nbsp; It requires the ability to compare whether the current visit and upcoming visit (_nxt_visit below) both have the same status when filtered as less-than 80.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  do _count=1 by 1 until (last.id or (sign(79.5-visit) ^= sign(79.5-_nxt_visit)));
    set have (keep=id);
	by id notsorted;
	merge have have(firstobs=2 keep=visit rename=(visit=_nxt_visit));
  end;

  do _i=1 to _count;
    set have;
	if _count=2 and visit&amp;lt;80 then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So now, instead of&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; DO _COUNT=1 BY 1 UNTIL (last._under80);&lt;/P&gt;
&lt;P&gt;I have&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; DO _COUNT=1 BY 1 UNTIL (LAST.ID or (SIGN(79.5-VISIT)^-SIGN(79.5-NXT_VISIT)));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The loops both stop at the same record.&amp;nbsp; Note I use SIGN(79.5-VISIT) for force the result to only be -1 or +1.&amp;nbsp; If I had used SIGN(80-VISIT), then the sign could also be zero (for visit=80).&amp;nbsp; I would have gotten the same output dataset, but the visit=80 records would be unnecessarily treated as their own group,&amp;nbsp; &amp;nbsp;And this tactic works fine as long as VISIT values are integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The real "trick" here is using the self merge with a "FIRSTOBS=2" option as a way to compare current and upcoming VISIT values.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 18:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707124#M26449</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-19T18:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707169#M26457</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Two minds thinking alike. My suggested solution would have looked VERY similar (just different variable names).&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;See how important a well-stated question is? Study the double DO loop, it is one of the must-have tools for a data step coder.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 13:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-consecutive-values/m-p/707169#M26457</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-19T13:13:57Z</dc:date>
    </item>
  </channel>
</rss>

