<?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: Running count by group through time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813301#M320954</link>
    <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;for the quick help! Yes your solutions works well. I was stuck on the issue that I had to sort the dataset by id1 and id2 before counting, which would mess up the time sequence. It is easily solved by sorting the dataset by id1, id2 &amp;amp; time.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 May 2022 20:09:39 GMT</pubDate>
    <dc:creator>Navyblue222</dc:creator>
    <dc:date>2022-05-13T20:09:39Z</dc:date>
    <item>
      <title>Running count by group through time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813292#M320946</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello. I have a dataset looks like the one provided below and need to count (not distinct) values of id2&amp;nbsp; by id1 through time (runningcount is the variable that I want). I have read the existing discussion on this topic (&lt;A href="https://communities.sas.com/t5/SAS-Programming/Running-count-distinct-by-group-through-time/td-p/438839" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Running-count-distinct-by-group-through-time/td-p/438839&lt;/A&gt;) and the 2 solutions works well for the original question. However, I need to restart the count when id2 changes (while keeping time in descending order). &lt;/SPAN&gt;&lt;SPAN&gt;Data is sorted by id1 and time.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Thank you in advance.&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;id1 id2 time runningcount&lt;BR /&gt;1 A 20131128 1&lt;BR /&gt;1 A 20140530 2&lt;BR /&gt;1 A 20150217 3&lt;BR /&gt;1 B 20150410 1&lt;BR /&gt;1 B 20160612 2&lt;BR /&gt;1 B 20180101 3&lt;BR /&gt;1 C 20190101 1&lt;BR /&gt;2 A 19900515 1&lt;BR /&gt;2 A 19910522 2&lt;BR /&gt;2 B 19920101 1&lt;BR /&gt;2 B 19930321 2&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 18:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813292#M320946</guid>
      <dc:creator>Navyblue222</dc:creator>
      <dc:date>2022-05-13T18:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Running count by group through time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813294#M320948</link>
      <description>&lt;P&gt;You essentially want a consecutive sequence number, reset to 1 each time a new ID2 is encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data are sorted by ID1/ID2, then&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id1 id2;
  if first.id2 then running_count=1;
  else running_count+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 19:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813294#M320948</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-13T19:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Running count by group through time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813301#M320954</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;for the quick help! Yes your solutions works well. I was stuck on the issue that I had to sort the dataset by id1 and id2 before counting, which would mess up the time sequence. It is easily solved by sorting the dataset by id1, id2 &amp;amp; time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 20:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-count-by-group-through-time/m-p/813301#M320954</guid>
      <dc:creator>Navyblue222</dc:creator>
      <dc:date>2022-05-13T20:09:39Z</dc:date>
    </item>
  </channel>
</rss>

