<?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 compile contious visit dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450803#M113565</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
   set have;
   by client;
   lagdate = lag(date);
   if first.client then episode=1;
     else if date-lagdate&amp;gt;1 then episode+1;
run;

proc summary data=have2;
  by client episode;
  var date;
  output out=want(drop=_: episode) min=start_date max=stop_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Another approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Apr 2018 18:52:04 GMT</pubDate>
    <dc:creator>SDally</dc:creator>
    <dc:date>2018-04-03T18:52:04Z</dc:date>
    <item>
      <title>how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450747#M113538</link>
      <description>&lt;P&gt;Hello SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question on how to consolidate dates to start and end date by client where the dates are continuous&lt;/P&gt;&lt;P&gt;What I have is data on each client and each day they had a visit. (see SAS code below).&lt;/P&gt;&lt;P&gt;What I want is that if there has not been a break in a visit, so a client came in everyday, then to have a start date and end date. if there was&amp;nbsp;a break in a visit then to have a new row that has a new start date and end date (see want table below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions on how to accomplish this? I am sure the code is really simple but cannot seem to figure it out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&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;
informat client 1. date mmddyy10.;
input client date;
format date mmddyy10.;
datalines;
1	10122017
1	10132017
1	10142017
1	10152017
1	10162017
1	10172017
1	10182017
1	10192017
1	10212017
1	10222017
1	10232017
1	10242017
1	10252017
1	10262017
1	10272017
2	01172017
2	01182017
2	01192017
2	01202017
2	01232017
2	01242017
2	01252017
2	01262017
2	01272017
3	05042017
3	05052017
3	05062017
3	05072017
3	05082017
3	05092017
3	05102017
3	05112017
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Client&lt;/TD&gt;&lt;TD&gt;Start_date&lt;/TD&gt;&lt;TD&gt;end_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10/12/2017&lt;/TD&gt;&lt;TD&gt;10/19/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10/21/2017&lt;/TD&gt;&lt;TD&gt;10/27/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1/17/2017&lt;/TD&gt;&lt;TD&gt;1/20/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1/23/2017&lt;/TD&gt;&lt;TD&gt;1/27/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5/4/2017&lt;/TD&gt;&lt;TD&gt;5/11/2017&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 16:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450747#M113538</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2018-04-03T16:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450749#M113539</link>
      <description>&lt;P&gt;Try the DIF function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If DIF() &amp;gt; 1 then that's the end and you need to start a new record/entry.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103523"&gt;@sas_student1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question on how to consolidate dates to start and end date by client where the dates are continuous&lt;/P&gt;
&lt;P&gt;What I have is data on each client and each day they had a visit. (see SAS code below).&lt;/P&gt;
&lt;P&gt;What I want is that if there has not been a break in a visit, so a client came in everyday, then to have a start date and end date. if there was&amp;nbsp;a break in a visit then to have a new row that has a new start date and end date (see want table below).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggestions on how to accomplish this? I am sure the code is really simple but cannot seem to figure it out&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&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;
informat client 1. date mmddyy10.;
input client date;
format date mmddyy10.;
datalines;
1	10122017
1	10132017
1	10142017
1	10152017
1	10162017
1	10172017
1	10182017
1	10192017
1	10212017
1	10222017
1	10232017
1	10242017
1	10252017
1	10262017
1	10272017
2	01172017
2	01182017
2	01192017
2	01202017
2	01232017
2	01242017
2	01252017
2	01262017
2	01272017
3	05042017
3	05052017
3	05062017
3	05072017
3	05082017
3	05092017
3	05102017
3	05112017
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need is:&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Client&lt;/TD&gt;
&lt;TD&gt;Start_date&lt;/TD&gt;
&lt;TD&gt;end_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;10/12/2017&lt;/TD&gt;
&lt;TD&gt;10/19/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;10/21/2017&lt;/TD&gt;
&lt;TD&gt;10/27/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1/17/2017&lt;/TD&gt;
&lt;TD&gt;1/20/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1/23/2017&lt;/TD&gt;
&lt;TD&gt;1/27/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;5/4/2017&lt;/TD&gt;
&lt;TD&gt;5/11/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 16:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450749#M113539</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-03T16:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450754#M113542</link>
      <description>&lt;P&gt;Determining whether the record in hand is the start of a new time-span is relatively easy.&amp;nbsp; But verifying that the record-in-hand is the END of a time-span requires looking ahead at the next record.&amp;nbsp; This program achieves that task via a data step with a self-merge and a "firstobs=2" parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=client start_date end_date);
  merge have 
        have (firstobs=2 keep=client date rename=(client=nxt_client date=nxt_date));

  retain start_date;

  if client^=nxt_client or nxt_date&amp;gt;date+1 then do;
    end_date=date;
    output;
    start_date=nxt_date;
  end;
  format start_date end_date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 17:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450754#M113542</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T17:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450771#M113547</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat client 1. date mmddyy10.;
input client date;
format date mmddyy10.;
datalines;
1	10122017
1	10132017
1	10142017
1	10152017
1	10162017
1	10172017
1	10182017
1	10192017
1	10212017
1	10222017
1	10232017
1	10242017
1	10252017
1	10262017
1	10272017
2	01172017
2	01182017
2	01192017
2	01202017
2	01232017
2	01242017
2	01252017
2	01262017
2	01272017
3	05042017
3	05052017
3	05062017
3	05072017
3	05082017
3	05092017
3	05102017
3	05112017
;
run;

data want;

set have;
by client;

k=dif(date);
retain startdate enddate;

if first.client then startdate=date;
else if k=1 then enddate=date;

if  not first.client and k&amp;gt;1 or last.client and k=1  then do;

    output;startdate=date;
    call missing(enddate);

end;

format startdate enddate mmddyy10.;
keep client startdate enddate;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450771#M113547</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T18:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450777#M113549</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; Note that your code got a bit garbled so I cleaned it up to show properly. This seems to happen if you edit code in the main window rather than the specific pop up.</description>
      <pubDate>Tue, 03 Apr 2018 18:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450777#M113549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-03T18:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450781#M113553</link>
      <description>&lt;P&gt;&amp;nbsp;thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;this almost worked!&lt;/P&gt;&lt;P&gt;I am missing the first start date for the first client .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the table looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;client&lt;/TD&gt;&lt;TD&gt;start_date&lt;/TD&gt;&lt;TD&gt;end_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;10/19/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10/21/2017&lt;/TD&gt;&lt;TD&gt;10/27/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1/17/2017&lt;/TD&gt;&lt;TD&gt;1/20/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1/23/2017&lt;/TD&gt;&lt;TD&gt;1/27/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5/4/2017&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5/11/2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do I get the 10/12/17 in the . ?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450781#M113553</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2018-04-03T18:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450785#M113555</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103523"&gt;@sas_student1&lt;/a&gt;:&amp;nbsp; You have observed that only one case of START_DATE is not as desired, then first time span.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a student, this is a good opportunity to implement some thing you probably know, or at least something worthwhile for every student to learn.&amp;nbsp; Namely:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;How to issue a statement that effectively says&amp;nbsp; "if this is the first iteration of the data step then initialize the START_DATE value to an appropriate value"&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;That is, a statement such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if&amp;nbsp;&amp;nbsp;&amp;nbsp; (some condition)&amp;nbsp; then start_date = (some value);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, what's the condition,&amp;nbsp; and what's the value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450785#M113555</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T18:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450791#M113556</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;thank you!&lt;/P&gt;&lt;P&gt;okay so to your question "whats the condition and whats the value" I would think it would be :&lt;/P&gt;&lt;P&gt;if first.client and first.date then start_date= date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But that is not exactly right, is it? I tried it and it didn't work.&lt;/P&gt;&lt;P&gt;the dif(date) by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;and the fix by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;did work, but trying to figure out (how/why) and how do I alter &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;code to get the first clients date not missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450791#M113556</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2018-04-03T18:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450794#M113558</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; just a quick question please. I tend to write the code in the PC SAS at my college lab and paste here using the running man icon as it pops a small window. I was told the same as what you said by an OP in another thread. Is something wrong at my end or am i doing not right?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the trivial stuff, I just wanna get this right. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450794#M113558</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T18:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450799#M113563</link>
      <description>&lt;P&gt;thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;question: what does the&lt;/P&gt;&lt;P&gt;call missing (enddate) do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450799#M113563</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2018-04-03T18:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450803#M113565</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
   set have;
   by client;
   lagdate = lag(date);
   if first.client then episode=1;
     else if date-lagdate&amp;gt;1 then episode+1;
run;

proc summary data=have2;
  by client episode;
  var date;
  output out=want(drop=_: episode) min=start_date max=stop_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Another approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450803#M113565</guid>
      <dc:creator>SDally</dc:creator>
      <dc:date>2018-04-03T18:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450804#M113566</link>
      <description>&lt;P&gt;assigns missing values exactly as documented. I googled it too.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450804#M113566</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T18:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450815#M113571</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29766"&gt;@SDally&lt;/a&gt;&amp;nbsp;yes this worked too!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450815#M113571</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2018-04-03T19:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450823#M113573</link>
      <description>&lt;P&gt;As a rule, I find it easier to handle this type of problem in two steps instead of one.&amp;nbsp; First, find the groupings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by client;&lt;/P&gt;
&lt;P&gt;if first.client or dif(date) ne 1 then group + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then find the endpoints:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=temp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by client group;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=want (keep=client start_date end_date) min=start_date max=end_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;************ EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry, didn't notice a very similar solution.&amp;nbsp; However, notice that this condition is not sufficient:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;lagdate&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token number"&gt;If one client started earlier than the previous client, the value for that expression could be negative.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450823#M113573</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-03T19:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450873#M113585</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; just a quick question please. I tend to write the code in the PC SAS at my college lab and paste here using the running man icon as it pops a small window. I was told the same as what you said by an OP in another thread. Is something wrong at my end or am i doing not right?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for the trivial stuff, I just wanna get this right. Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There seems to be some intermittent behavior with things pasted into the "running man" and I have no idea what causes it. Sometimes the result will show as&amp;nbsp;a "spoiler" with a right arrow instead of inline displayed text, sometimes text gets scrambled in other ways, possibly the result of characters that you do not see if you copy code from online (message windows here for example), edit and paste back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tend to use the {I} as it seems more of a "pure text" format, no color highlighting for example. But even there I've seen some odd things happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just check the appearance of your post after it posts and edit if needed by clicking on the wheel to the upper right of the posted message and selecting "edit".&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 20:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450873#M113585</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-03T20:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450880#M113587</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thank you Sir. Hmm sounds like a remedy ticket needs to be raised with community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I will be more aware. Thank you for your time. Have a nice evening!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 20:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450880#M113587</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-03T20:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to compile contious visit dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450893#M113592</link>
      <description>&lt;P&gt;The "then start_date=date" is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "if first.client and first.date" condition would be wrong, because:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;There is no BY statement to even generate the first.client and first.date dummy variables&lt;/LI&gt;
&lt;LI&gt;Even if there were, the condition ("first.client and first.date") would select EVERY observation from a daily file.
&lt;OL&gt;
&lt;LI&gt;But a "first.client" alone would work, although it's overkill.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I meant was&lt;/P&gt;
&lt;P&gt;&amp;nbsp; "if _N_=1 then start_date=date;"&lt;/P&gt;
&lt;P&gt;placed in front of the do group.&amp;nbsp; The automatic variable _N_ counts the current iteration number in the DATA step.&amp;nbsp; In this sample _N_ is tracking&amp;nbsp;the number of MERGE actions&amp;nbsp; (once for each incoming observation).&amp;nbsp; So _N_=1 is the first observation.&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;
&lt;P&gt;. It&amp;nbsp;selects the first record for a givne client/date - which means every record in your daily file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now "if first.client" would work, but is a sligh&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 21:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-compile-contious-visit-dates/m-p/450893#M113592</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-04-03T21:13:23Z</dc:date>
    </item>
  </channel>
</rss>

