<?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 Cumulative Counter Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783040#M249630</link>
    <description>&lt;P&gt;I am trying to create a cumulative counter variable that tracks the total number games. The code I have been using can be found below. I am not sure how to word it so that the TotalGames column adds 1 for each new game, sorted by date. That way that the count is totaled based on the dates the games were played.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT data = NewRoseBowl;&lt;BR /&gt;by Date;&lt;BR /&gt;RUN;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data CountRoseBowl;&lt;BR /&gt;set NewRoseBowl;&lt;BR /&gt;TotalGames + 1;&lt;BR /&gt;by Date;&lt;BR /&gt;if first.date then TotalGames = 1;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;Format Date WEEKDATE30.;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Nov 2021 22:33:32 GMT</pubDate>
    <dc:creator>collegestudent2</dc:creator>
    <dc:date>2021-11-29T22:33:32Z</dc:date>
    <item>
      <title>Cumulative Counter Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783040#M249630</link>
      <description>&lt;P&gt;I am trying to create a cumulative counter variable that tracks the total number games. The code I have been using can be found below. I am not sure how to word it so that the TotalGames column adds 1 for each new game, sorted by date. That way that the count is totaled based on the dates the games were played.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT data = NewRoseBowl;&lt;BR /&gt;by Date;&lt;BR /&gt;RUN;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data CountRoseBowl;&lt;BR /&gt;set NewRoseBowl;&lt;BR /&gt;TotalGames + 1;&lt;BR /&gt;by Date;&lt;BR /&gt;if first.date then TotalGames = 1;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;Format Date WEEKDATE30.;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 22:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783040#M249630</guid>
      <dc:creator>collegestudent2</dc:creator>
      <dc:date>2021-11-29T22:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Counter Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783057#M249639</link>
      <description>&lt;P&gt;Do you want the total number of games for each date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, why not run a PROC FREQ on the DATE variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need for sorting, or a data step.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 02:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783057#M249639</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-11-30T02:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Counter Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783068#M249645</link>
      <description>It looks like you need to add the name of the variable that indicates what the game is, as in:&lt;BR /&gt;&lt;BR /&gt;proc sort;&lt;BR /&gt;by game_type date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data CountRoseBowl;&lt;BR /&gt;set NewRoseBowl;&lt;BR /&gt;by game_type date;&lt;BR /&gt;&lt;BR /&gt;/* set up counter */&lt;BR /&gt;if first.date then game_cnt = 1;&lt;BR /&gt;else game_cnt + 1;&lt;BR /&gt;&lt;BR /&gt;/* output last record by GAME_TYPE to get total sum */&lt;BR /&gt;if last.game_type;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 30 Nov 2021 06:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Counter-Variable/m-p/783068#M249645</guid>
      <dc:creator>BrianB4233</dc:creator>
      <dc:date>2021-11-30T06:06:15Z</dc:date>
    </item>
  </channel>
</rss>

