<?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: Summing over the column in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58120#M16239</link>
    <description>You should actually sort "by ID Date Time" to make sure it is all in order.</description>
    <pubDate>Tue, 16 Feb 2010 18:26:01 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2010-02-16T18:26:01Z</dc:date>
    <item>
      <title>Summing over the column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58118#M16237</link>
      <description>I have the following data:&lt;BR /&gt;
Data mydata;&lt;BR /&gt;
 Date              Time               Sales              ID&lt;BR /&gt;
03/01/2008    08:39:18           22.99               0&lt;BR /&gt;
03/01/2008    08:41:21           12.99               0&lt;BR /&gt;
03/01/2008    08:42:13           12.99               0&lt;BR /&gt;
03/02/2008    08:07:19           22.99               0&lt;BR /&gt;
03/02/2008    09:06:20           22.99               0&lt;BR /&gt;
02/03/2008    11:51:18           12.99               0&lt;BR /&gt;
02/01/2008    14:31:42           22.99               1&lt;BR /&gt;
02/07/2008    12:17:27           22.99               1&lt;BR /&gt;
02/07/2008    13:42:27           22.99               1&lt;BR /&gt;
02/07/2008    13:58:37           12.99               1&lt;BR /&gt;
02/07/2008    15:03:23           12.99               1&lt;BR /&gt;
&lt;BR /&gt;
I will like to compute sales by time Vi(A) the agent (ID) accrued at time say ti(A). That is I will to have something that looks like this&lt;BR /&gt;
&lt;BR /&gt;
Date              Time               Sales              ID     totalsales&lt;BR /&gt;
03/01/2008    08:39:18           22.99               0      22.99&lt;BR /&gt;
03/01/2008    08:41:21           12.99               0      35.98 &lt;BR /&gt;
03/01/2008    08:42:13           12.99               0      48.97&lt;BR /&gt;
03/02/2008    08:07:19           22.99               0       22.99&lt;BR /&gt;
03/02/2008    09:06:20           22.99               0       45.98 &lt;BR /&gt;
02/03/2008    11:51:18           12.99               0        12.99&lt;BR /&gt;
02/01/2008    14:31:42           22.99               1         22.99&lt;BR /&gt;
02/07/2008    12:17:27           22.99               1         22.99&lt;BR /&gt;
02/07/2008    13:42:27           22.99               1         45.98        &lt;BR /&gt;
02/07/2008    13:58:37           12.99               1        68.97&lt;BR /&gt;
02/07/2008    15:03:23           12.99               1        91.96&lt;BR /&gt;
&lt;BR /&gt;
I will appreciate it if you can help.</description>
      <pubDate>Tue, 16 Feb 2010 17:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58118#M16237</guid>
      <dc:creator>Statsconsultancy</dc:creator>
      <dc:date>2010-02-16T17:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summing over the column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58119#M16238</link>
      <description>First you should sort by ID.  Then in a data step do something like:&lt;BR /&gt;
&lt;BR /&gt;
retain totalsales;&lt;BR /&gt;
if first.id then total sales=0;&lt;BR /&gt;
totalsales=totalsales+sales;&lt;BR /&gt;
&lt;BR /&gt;
*not tested</description>
      <pubDate>Tue, 16 Feb 2010 18:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58119#M16238</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-02-16T18:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Summing over the column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58120#M16239</link>
      <description>You should actually sort "by ID Date Time" to make sure it is all in order.</description>
      <pubDate>Tue, 16 Feb 2010 18:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58120#M16239</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-02-16T18:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Summing over the column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58121#M16240</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
You might want to try the code below, and check whether you get the right output. Here at different dates of a single agent you get the sales cumulative as it starts with that date. &lt;BR /&gt;
&lt;BR /&gt;
It got a bit complicated in the end, but it would work.&lt;BR /&gt;
Any other better solutions are welcome.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;B&gt;&lt;BR /&gt;
data test;&lt;BR /&gt;
input date: ddmmyy10. time: time8. sales id;&lt;BR /&gt;
cards;&lt;BR /&gt;
03/01/2008 08:39:18 22.99 0&lt;BR /&gt;
03/01/2008 08:41:21 12.99 0&lt;BR /&gt;
03/01/2008 08:42:13 12.99 0&lt;BR /&gt;
03/02/2008 08:07:19 22.99 0&lt;BR /&gt;
03/02/2008 09:06:20 22.99 0&lt;BR /&gt;
02/03/2008 11:51:18 12.99 0&lt;BR /&gt;
02/01/2008 14:31:42 22.99 1&lt;BR /&gt;
02/07/2008 12:17:27 22.99 1&lt;BR /&gt;
02/07/2008 13:42:27 22.99 1&lt;BR /&gt;
02/07/2008 13:58:37 12.99 1&lt;BR /&gt;
02/07/2008 15:03:23 12.99 1&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=test;&lt;BR /&gt;
by id date time;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data final;&lt;BR /&gt;
set test;&lt;BR /&gt;
by ID date;&lt;BR /&gt;
if first.id then&lt;BR /&gt;
if first.date then&lt;BR /&gt;
sales_cummulative=sales;&lt;BR /&gt;
else&lt;BR /&gt;
sales_cummulative+sales;&lt;BR /&gt;
else if first.date then sales_cummulative=sales;&lt;BR /&gt;
else&lt;BR /&gt;
sales_cummulative+sales;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;/B&gt;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Saurabh.</description>
      <pubDate>Wed, 17 Feb 2010 06:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summing-over-the-column/m-p/58121#M16240</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-17T06:45:37Z</dc:date>
    </item>
  </channel>
</rss>

