<?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: Need help on Loop and lag for continue enrollment counting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406683#M99057</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your prompt reply, could you specify what do you mean by using lag?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did this&lt;/P&gt;&lt;P&gt;I've created this multiple_enroll flag, if it ne 1, it means this person has multiple rows&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Step6_I4;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Step6_I3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; multiple_enroll ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;gap = enr_start_date - lag(enr_end_date);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives me this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16157i97BF96C2AE7DCDD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I let SAS only calculate the gap starting from the second row of each person with multiple entries? So it won't have values like&lt;FONT color="#ff0000"&gt; -364 &lt;/FONT&gt;shows up (it used person 1's end date and person 2's start date to calculate).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 18:26:31 GMT</pubDate>
    <dc:creator>LisaYIN9309</dc:creator>
    <dc:date>2017-10-23T18:26:31Z</dc:date>
    <item>
      <title>Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406661#M99047</link>
      <description>&lt;P&gt;Hi I would need your help with my loop and lag gap, Loop is something I am not proficient on, so I haven't make my code work for my purpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to count days of enrollment of each person in 2015, and my problem is with those who have more than one row of entries (they dropped and re-enrolled). My continuous enrollment standard is that as long as no single enrollment gap &amp;gt; 45 days, this person is continued enrolled (continue_enroll_flag = 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My attempt method:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If the person has only one row of entry,&amp;nbsp;Gap = 365 - (enrollment_end - enrollment_start)&lt;/LI&gt;&lt;LI&gt;If the person has multiple rows:&amp;nbsp; I am thinking using code gap = enrollment_start - lag(enrollment_end)&lt;/LI&gt;&lt;LI&gt;Then create continuous_enroll_flag: if Gap &amp;gt; 45 then continuous_enroll_flag = 0; else, continuous_enroll_flag = 1;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Loop is something I've always messed up with, so I would like someone to help me with it... (won't post my code because I kinda don't know how to start, I am thinking something like if first.enrollment_start, maybe wrong)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data looks like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;person_id&lt;/TD&gt;&lt;TD&gt;enrollment_start&lt;/TD&gt;&lt;TD&gt;Enrollment_end&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;3/1/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6/2/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;7/1/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;8/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;10/25/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;4/6/2015&lt;/TD&gt;&lt;TD&gt;12/1/2015&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my desired output looks like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;person_id&lt;/TD&gt;&lt;TD&gt;enrollment_start&lt;/TD&gt;&lt;TD&gt;Enrollment_end&lt;/TD&gt;&lt;TD&gt;EnrollmentDays&lt;/TD&gt;&lt;TD&gt;EnrollmentGap&lt;/TD&gt;&lt;TD&gt;Continue_enroll_Flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;3/1/2015&lt;/TD&gt;&lt;TD&gt;59&lt;/TD&gt;&lt;TD&gt;93&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6/2/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;TD&gt;212&lt;/TD&gt;&lt;TD&gt;93&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;TD&gt;333&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;TD&gt;364&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;TD&gt;305&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;7/1/2015&lt;/TD&gt;&lt;TD&gt;181&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;8/1/2015&lt;/TD&gt;&lt;TD&gt;12/31/2015&lt;/TD&gt;&lt;TD&gt;152&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;10/25/2015&lt;/TD&gt;&lt;TD&gt;297&lt;/TD&gt;&lt;TD&gt;68&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;4/6/2015&lt;/TD&gt;&lt;TD&gt;12/1/2015&lt;/TD&gt;&lt;TD&gt;239&lt;/TD&gt;&lt;TD&gt;126&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 17:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406661#M99047</guid>
      <dc:creator>LisaYIN9309</dc:creator>
      <dc:date>2017-10-23T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406674#M99055</link>
      <description>&lt;P&gt;A data set implicitly loops so there's no need for loops here at all. Use LAG() to get the previous value when needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 18:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406674#M99055</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-23T18:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406683#M99057</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your prompt reply, could you specify what do you mean by using lag?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did this&lt;/P&gt;&lt;P&gt;I've created this multiple_enroll flag, if it ne 1, it means this person has multiple rows&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Step6_I4;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Step6_I3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; multiple_enroll ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;gap = enr_start_date - lag(enr_end_date);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives me this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16157i97BF96C2AE7DCDD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I let SAS only calculate the gap starting from the second row of each person with multiple entries? So it won't have values like&lt;FONT color="#ff0000"&gt; -364 &lt;/FONT&gt;shows up (it used person 1's end date and person 2's start date to calculate).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 18:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406683#M99057</guid>
      <dc:creator>LisaYIN9309</dc:creator>
      <dc:date>2017-10-23T18:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406696#M99065</link>
      <description>&lt;P&gt;LAG() cannot be calculated conditionally, or at least then it doesn't behave the way you expect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this example here to get you started:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat person_id $1. date_enroll_start date_enroll_end mmddyy10.;
format date_: date9.;
input person_id date_enroll_start date_enroll_end;
cards;
1	1/1/2015	3/1/2015
1	6/2/2015	12/31/2015
2	2/1/2015	12/31/2015
3	1/1/2015	12/31/2015
4	3/1/2015	12/31/2015
5	1/1/2015	7/1/2015
5	8/1/2015	12/31/2015
6	1/1/2015	10/25/2015
7	4/6/2015	12/1/2015
;
run;

data want;
set have;
by person_id;

lag_enroll_end = lag(date_enroll_end);

if first.person_id then gap = 365 - date_enroll_end + date_enroll_start;
else gap = date_enroll_start - lag_enroll_end;

format lag_enroll_end date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Oct 2017 18:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406696#M99065</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-23T18:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406707#M99068</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;. this code creates the exact same problem as my old code gives me, instead of giving a negative values derived from using previous person's enrollment end date, it gives a positive value, but the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 510px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16161iD1E97021650A0369/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406707#M99068</guid>
      <dc:creator>LisaYIN9309</dc:creator>
      <dc:date>2017-10-23T19:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406710#M99070</link>
      <description>&lt;P&gt;I'm not seeing those numbers based on the sample data provided so can please explain the issue in more detail?&lt;/P&gt;
&lt;P&gt;I'm not seeing an issue, so you may need to expand your sample data to better reflect your actual data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF/BY processing prevents some one elses data from rolling over, ie the calculation varies depending on the person's record.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406710#M99070</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-23T19:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406719#M99074</link>
      <description>&lt;P&gt;Thank you for asking &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, sorry I should have been more clear on it. You are right, the calculation is based on person_id, so no other person's data is rolled into the calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I want to delete a person whose real largest single gap &amp;gt; 45, which means if a person has three rows, all three rows will be deleted. this won't work with this output :&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 510px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16163i663C057EB1488AE1/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;because the first gap number of this person, 214, is not the real gap.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e. (I made this up) A person's real largest single gap is 31, this person shouldn't be deleted, how should I manage it?&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;7/1/2015&lt;/TD&gt;&lt;TD&gt;20089&lt;/TD&gt;&lt;TD&gt;20453&lt;/TD&gt;&lt;TD&gt;31-Dec-15&lt;/TD&gt;&lt;TD&gt;183&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8/1/2015&lt;/TD&gt;&lt;TD&gt;11/30/2015&lt;/TD&gt;&lt;TD&gt;20089&lt;/TD&gt;&lt;TD&gt;20453&lt;/TD&gt;&lt;TD&gt;31-Dec-15&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to make something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1/1/2015&lt;/TD&gt;&lt;TD&gt;7/1/2015&lt;/TD&gt;&lt;TD&gt;20089&lt;/TD&gt;&lt;TD&gt;20453&lt;/TD&gt;&lt;TD&gt;31-Dec-15&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8/1/2015&lt;/TD&gt;&lt;TD&gt;11/30/2015&lt;/TD&gt;&lt;TD&gt;20089&lt;/TD&gt;&lt;TD&gt;20453&lt;/TD&gt;&lt;TD&gt;31-Dec-15&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this is clear.&lt;/P&gt;&lt;P&gt;Thank you for constantly helping out on this!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406719#M99074</guid>
      <dc:creator>LisaYIN9309</dc:creator>
      <dc:date>2017-10-23T19:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on Loop and lag for continue enrollment counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406723#M99076</link>
      <description>&lt;P&gt;You'll need multiple steps to do this, not one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First find the lags, then find the IDs you need to erase. Then select the people you want included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *
from YourData 
where ID not in (Select id from YourData where gap&amp;gt;45);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-Loop-and-lag-for-continue-enrollment-counting/m-p/406723#M99076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-23T19:24:45Z</dc:date>
    </item>
  </channel>
</rss>

