<?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 code for continous enrollment using LAG and RETAIN function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459774#M116814</link>
    <description>&lt;P&gt;Are you guaranteeing that there are no gaps in the dates?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are gaps in the dates would you want a second observation for the same ID?&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 17:54:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-05-03T17:54:10Z</dc:date>
    <item>
      <title>how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459769#M116811</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create&amp;nbsp; a continous enrollment dataset from a dataset which has enrollment for all months across 2011-2017. The dataset I have looks&amp;nbsp; like this :&lt;/P&gt;&lt;P&gt;enrolid&amp;nbsp; dtstart&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dtend&lt;/P&gt;&lt;P&gt;420&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;07/02/2011&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;07/31/2011&lt;/P&gt;&lt;P&gt;420&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08/01/2011&amp;nbsp; &amp;nbsp; &amp;nbsp;08/31/2011&lt;/P&gt;&lt;P&gt;420&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/01/2011&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09/30/2011&lt;/P&gt;&lt;P&gt;500&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;07/02/2011&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;07/31/2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only want a dataset looking like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;enrolid&amp;nbsp; &amp;nbsp; period_start&amp;nbsp; period_stop&lt;/P&gt;&lt;P&gt;420&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07/01/2011&amp;nbsp; &amp;nbsp; 09/30/2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i do this using retain and lag functions ?&lt;/P&gt;&lt;P&gt;There should be no gaps in the dates.. they should be continous&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Batch SAS&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459769#M116811</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T17:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459772#M116812</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input enrolid  dtstart   :mmddyy10.             dtend   :mmddyy10.  ;
format dtstart             dtend   mmddyy10.  ;
cards;
420       07/02/2011       07/31/2011
420        08/01/2011     08/31/2011
420       09/01/2011        09/30/2011
500       07/02/2011         07/31/2011
;
 

proc sql;
create table want as
select enrolid, min(dtstart) as period_start   format= mmddyy10. ,max(dtend) as period_stop  format= mmddyy10.
from have
group by enrolid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 17:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459772#M116812</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-03T17:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459773#M116813</link>
      <description>&lt;P&gt;I am new to sql could you show how to do this using SAS retain and lag functions ?&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459773#M116813</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T17:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459774#M116814</link>
      <description>&lt;P&gt;Are you guaranteeing that there are no gaps in the dates?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are gaps in the dates would you want a second observation for the same ID?&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459774#M116814</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-03T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459775#M116815</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by enrolid;
retain _t;
if first.enrolid then _t=dtstart;
if last.enrolid then do;period_start=_t;
period_stop=dtend;output;end;
format period_start period_stop mmddyy10.;
drop dt: _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note: This assumes your dataset is sorted&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459775#M116815</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-03T17:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459778#M116816</link>
      <description>&lt;P&gt;I don't see a need for RETAIN here.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assumes data is sorted by ENROLID and DTSTART.&lt;/P&gt;
&lt;P&gt;*** UNTESTED CODE ***&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by enrolid;
    prev_dtend=lag(dtend);
    if dtstart ^= prev_dtend+1 then continuous_dates+1;
run;
proc summary nway data=want;
    class enrolid continuous_dates;
    var dtstart dtend;
    output out=want2 min(dtstart)=period_start max(dtend)=period_stop;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 18:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459778#M116816</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-03T18:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459780#M116817</link>
      <description>&lt;P&gt;You don't need a lag for this task.&amp;nbsp; But retain is useful:&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 want;
  set have  (rename=(dtend=dtend_last));
  by enrolid;
  if first.enrolid then dtstart_beg=dtstart;
  retain dtstart_beg;
  if last.enrolid;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 18:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459780#M116817</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-03T18:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459782#M116818</link>
      <description>&lt;P&gt;There are gaps in the data.&lt;/P&gt;&lt;P&gt;if the gap is more than a day we have another row for the same enrolid..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 18:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459782#M116818</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T18:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459783#M116819</link>
      <description>&lt;P&gt;This doesn't meet the user requirement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;There should be no gaps in the dates.. they should be continous&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 03 May 2018 18:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459783#M116819</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-03T18:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459791#M116821</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;.&amp;nbsp; I wasn't paying sufficient attention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now lag helps in detecting start of a new time span.&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 want;
  set have;
  by enrolid;

  merge have (           keep=dtend  rename=(dtend=dtend_last))
        have (firstobs=2 keep=dtstart rename=(dtstart=dtstart_next));

  if first.enrolid or dtstart&amp;gt;sum(lag(dtend),1) then dtstart_beg=dtstart;
  retain dtstart_beg;

  if last.enrolid or dtstart_next&amp;gt;dtend+1;
  drop dtstart dtend dtstart_next;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 18:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459791#M116821</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-03T18:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459806#M116825</link>
      <description>&lt;P&gt;There are gaps in the dates but whenever they are there we have another row for the enrollment id. gap means more than 1 day of no enrollment&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459806#M116825</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T19:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459816#M116829</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have  &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dtend&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;dtend_last&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; enrolid&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;enrolid &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; dtstart_beg&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;dtstart&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;retain&lt;/SPAN&gt; dtstart_beg&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; last&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;enrolid&lt;SPAN class="token punctuation"&gt;; &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/FONT&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;what do you mean by the line highlighted in red&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459816#M116829</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T19:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459818#M116830</link>
      <description>&lt;P&gt;and this does not work the same as sql&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459818#M116830</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T19:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459825#M116832</link>
      <description>&lt;P&gt;what does&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;dtstart&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;lag&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dtend&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;) &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;mean ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;and also i am not clear what this does ?&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; last&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;enrolid or dtstart_next&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;dtend&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 20:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459825#M116832</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-03T20:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459907#M116857</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/208127"&gt;@manya92&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;what does&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;dtstart&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;lag&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dtend&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;) &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;mean ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;and also i am not clear what this does ?&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; last&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;enrolid or dtstart_next&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;dtend&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;dtstart&amp;gt;sum*lag(dtend),1)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; is almost identical to&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;dtstart&amp;gt;lag(dtend)+1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; except the latter will generate an error note for the first observation - because lag of anything is missing for the first obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF statement above is a "subsetting if" - i.e. the data step only keeps cases that satisfy the&amp;nbsp; if expression.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 02:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/459907#M116857</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-04T02:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460108#M116937</link>
      <description>how can you have the set and merge statements in the same data step ?&lt;BR /&gt;</description>
      <pubDate>Fri, 04 May 2018 17:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460108#M116937</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-05-04T17:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460124#M116940</link>
      <description>&lt;P&gt;The SET statement starts one data stream, and the MERGE statement starts another data stream.&amp;nbsp;&amp;nbsp; And they are synchronized streams.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course if you have two streams of data from data set HAVE, you'll have any common variable being read once from each stream.&amp;nbsp; But you can't have two values occupy one variable, so I use the KEEP= and RENAME= parameters to avoid such collisions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SET statement is used for nothing more than to generate FIRST.ENROLID and LAST.ENROLID variables for easy detection of boundaries for each ID.&amp;nbsp; The MERGE statement has one of the merged sub-streams start at FIRSTOBS=2 so that you can look ahead one observation.&amp;nbsp; This makes it easy to tell if the next observation starts more than one day after the current obs ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 18:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460124#M116940</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-04T18:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to code for continous enrollment using LAG and RETAIN function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460126#M116941</link>
      <description>&lt;P&gt;No red line is showing up.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 18:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-code-for-continous-enrollment-using-LAG-and-RETAIN/m-p/460126#M116941</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-04T18:35:12Z</dc:date>
    </item>
  </channel>
</rss>

