<?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: cumulative sum, two variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562853#M157731</link>
    <description>&lt;P&gt;An alternative PROC SQL Approach. I like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;s code better though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input sinistre $ police $ datesurvenanace:ddmmyy10. prime1 prime2;
format datesurvenanace ddmmyy10.;
datalines;
S1 p1 01/01/2015 100 50
S2 p1 01/01/2015 0 80
S3 p1 20/06/2018 80 20
;

proc sql;
   create table want as
   select police,
          datesurvenanace,
          sum(prime1) as prime1,
          sum(prime2) as prime2
   from have
   group by police, datesurvenanace;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 May 2019 14:17:54 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-05-31T14:17:54Z</dc:date>
    <item>
      <title>cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562840#M157725</link>
      <description>&lt;P&gt;Hello, I need to transform this data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;sinistre&lt;/TD&gt;&lt;TD&gt;police&lt;/TD&gt;&lt;TD&gt;date survenanace&lt;/TD&gt;&lt;TD&gt;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In fact, for each "police", i have to sum the claims amount (prime 1 prime 2) of the claims (S1 and S2) which happen in the same date (date survenance),&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 13:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562840#M157725</guid>
      <dc:creator>Mirou</dc:creator>
      <dc:date>2019-05-31T13:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562849#M157729</link>
      <description>&lt;P&gt;This is a perfect example of where to use PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary nway data=have;
    class police date;
    var prime1 prime2;
    output out=want sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 14:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562849#M157729</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-31T14:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562853#M157731</link>
      <description>&lt;P&gt;An alternative PROC SQL Approach. I like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;s code better though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input sinistre $ police $ datesurvenanace:ddmmyy10. prime1 prime2;
format datesurvenanace ddmmyy10.;
datalines;
S1 p1 01/01/2015 100 50
S2 p1 01/01/2015 0 80
S3 p1 20/06/2018 80 20
;

proc sql;
   create table want as
   select police,
          datesurvenanace,
          sum(prime1) as prime1,
          sum(prime2) as prime2
   from have
   group by police, datesurvenanace;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 14:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562853#M157731</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-31T14:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562858#M157732</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;An alternative PROC SQL Approach. I like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;s code better though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks. In my opinion, PROC SUMMARY/PROC MEANS is a fundamental tool that every SAS user ought to be familiar with. An advantage over PROC SQL here is that if you take the option NWAY out of my example code, you get a lot more results from PROC SUMMARY easily (and which are meaningful in many situations), which would take a lot more effort to get from SQL.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562858#M157732</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-31T14:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562861#M157733</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Couldn't agree more. I have a habit of going with PROC MEANS. Though the Summary Procedure seems to handle situations like this smoother.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562861#M157733</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-31T14:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562864#M157735</link>
      <description>&lt;P&gt;thank you !&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562864#M157735</guid>
      <dc:creator>Mirou</dc:creator>
      <dc:date>2019-05-31T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562869#M157738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;An alternative PROC SQL Approach. I like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;s code better though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks. In my opinion, PROC SUMMARY/PROC MEANS is a fundamental tool that every SAS user ought to be familiar with. An advantage over PROC SQL here is that if you take the option NWAY out of my example code, you get a lot more results from PROC SUMMARY easily (and which are meaningful in many situations), which would take a lot more effort to get from SQL.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of my projects actually involves enough class variables and levels of those variables that the summary data is larger than the original but that one pass allows me to select combinations of the summarized variables for different audiences resulting in over a couple hundred different report documents customized for each audience without much fuss.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/562869#M157738</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-31T14:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative sum, two variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/563038#M157791</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Couldn't agree more. I have a habit of going with PROC MEANS. Though the Summary Procedure seems to handle situations like this smoother.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;MEANS and SUMMARY are the same procedure they just have different defaults, like printed output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SUMMARY is my favorite procedure. &lt;img id="robothappy" class="emoticon emoticon-robothappy" src="https://communities.sas.com/i/smilies/16x16_robot-happy.png" alt="Robot Happy" title="Robot Happy" /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 22:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-sum-two-variables/m-p/563038#M157791</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-05-31T22:46:59Z</dc:date>
    </item>
  </channel>
</rss>

