<?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: SAS code: count continuous records in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72995#M7249</link>
    <description>My code like this:&lt;BR /&gt;
&lt;BR /&gt;
Data Temp8;&lt;BR /&gt;
set temp7;&lt;BR /&gt;
by cusid date;&lt;BR /&gt;
if first.date=1 then do;&lt;BR /&gt;
Diff=intck('month', lag(timekey),timekey);&lt;BR /&gt;
if last.date =1 then output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Result:&lt;BR /&gt;
&lt;BR /&gt;
CusID  Date          Diff&lt;BR /&gt;
123     31/5/2007   .&lt;BR /&gt;
123     31/7/2007   2&lt;BR /&gt;
123     31/8/2007   1&lt;BR /&gt;
123     30/9/2007   1&lt;BR /&gt;
XYZ     31/7/2007  -2&lt;BR /&gt;
XYZ     31/1//2008  6&lt;BR /&gt;
XYZ     30/4/2008   3&lt;BR /&gt;
&lt;BR /&gt;
how to compare the same cusid and why there is a .?</description>
    <pubDate>Fri, 06 Feb 2009 08:15:28 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-02-06T08:15:28Z</dc:date>
    <item>
      <title>SAS code: count continuous records</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72993#M7247</link>
      <description>My dataset like this:&lt;BR /&gt;
&lt;BR /&gt;
CusID  Date&lt;BR /&gt;
123     31/5/2007&lt;BR /&gt;
123     31/7/2007&lt;BR /&gt;
123     31/8/2007&lt;BR /&gt;
123     30/9/2007&lt;BR /&gt;
XYZ    31/7/2007&lt;BR /&gt;
XYZ    31/1//2008&lt;BR /&gt;
XYZ    30/4/2008&lt;BR /&gt;
&lt;BR /&gt;
How can I find out which customer have 2 or more continuous month-end records?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 06 Feb 2009 07:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72993#M7247</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-06T07:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code: count continuous records</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72994#M7248</link>
      <description>You can use SET BY together with first.CustId to keep track on one customers records (so you don't compare dates between different customers).&lt;BR /&gt;
&lt;BR /&gt;
You can use RETAIN statement or the LAG() function to hold/retrieve values between observations.&lt;BR /&gt;
 &lt;BR /&gt;
The INTNX function lets you move your date monthly (among a lot of other valid intervals), which let you compare the dates between to observations.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 06 Feb 2009 07:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72994#M7248</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-02-06T07:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code: count continuous records</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72995#M7249</link>
      <description>My code like this:&lt;BR /&gt;
&lt;BR /&gt;
Data Temp8;&lt;BR /&gt;
set temp7;&lt;BR /&gt;
by cusid date;&lt;BR /&gt;
if first.date=1 then do;&lt;BR /&gt;
Diff=intck('month', lag(timekey),timekey);&lt;BR /&gt;
if last.date =1 then output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Result:&lt;BR /&gt;
&lt;BR /&gt;
CusID  Date          Diff&lt;BR /&gt;
123     31/5/2007   .&lt;BR /&gt;
123     31/7/2007   2&lt;BR /&gt;
123     31/8/2007   1&lt;BR /&gt;
123     30/9/2007   1&lt;BR /&gt;
XYZ     31/7/2007  -2&lt;BR /&gt;
XYZ     31/1//2008  6&lt;BR /&gt;
XYZ     30/4/2008   3&lt;BR /&gt;
&lt;BR /&gt;
how to compare the same cusid and why there is a .?</description>
      <pubDate>Fri, 06 Feb 2009 08:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72995#M7249</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-06T08:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code: count continuous records</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72996#M7250</link>
      <description>You don't need to do BY date, since date seems to unique, and you want to keep track on different CustId.&lt;BR /&gt;
Try to change to:&lt;BR /&gt;
&lt;BR /&gt;
if not first.CustId then do;&lt;BR /&gt;
Diff=intck('month', lag(timekey),timekey);&lt;BR /&gt;
if diff eq 1 then output;&lt;BR /&gt;
&lt;BR /&gt;
With this you have multiple records per custId in your output.&lt;BR /&gt;
The . means missing. You tried to compare a value from observation 1 minus 1, and that observation does not exist...&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Fri, 06 Feb 2009 08:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-code-count-continuous-records/m-p/72996#M7250</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-02-06T08:34:05Z</dc:date>
    </item>
  </channel>
</rss>

