<?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 calculations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70041#M15169</link>
    <description>the code below is not adding the var nor is it outputing the last line;  what am i missing&lt;BR /&gt;
Data test_me (keep = Date  Total_Calls  Total_LM);&lt;BR /&gt;
set Summary2 ;&lt;BR /&gt;
retain var1 var2;&lt;BR /&gt;
 var1 = 0;&lt;BR /&gt;
 var2 = 0;&lt;BR /&gt;
&lt;BR /&gt;
if not eof then do;&lt;BR /&gt;
 var1 = Total_ER_Calls + var1;&lt;BR /&gt;
 var2 = var2 + Total_ER_To_LM;&lt;BR /&gt;
 end;&lt;BR /&gt;
 &lt;BR /&gt;
if last._Date then do; &lt;BR /&gt;
Date= "Grand Total";&lt;BR /&gt;
Total_Calls = var1;&lt;BR /&gt;
Total_LM = var2;&lt;BR /&gt;
end;&lt;BR /&gt;
 &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
would like it to look like this;&lt;BR /&gt;
&lt;BR /&gt;
Date          Total_Calls       Total_LM&lt;BR /&gt;
1/1/2011          10                  5&lt;BR /&gt;
1/2/2011          15                  3&lt;BR /&gt;
grand total       25                  8</description>
    <pubDate>Thu, 26 May 2011 15:36:59 GMT</pubDate>
    <dc:creator>mick_g</dc:creator>
    <dc:date>2011-05-26T15:36:59Z</dc:date>
    <item>
      <title>calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70041#M15169</link>
      <description>the code below is not adding the var nor is it outputing the last line;  what am i missing&lt;BR /&gt;
Data test_me (keep = Date  Total_Calls  Total_LM);&lt;BR /&gt;
set Summary2 ;&lt;BR /&gt;
retain var1 var2;&lt;BR /&gt;
 var1 = 0;&lt;BR /&gt;
 var2 = 0;&lt;BR /&gt;
&lt;BR /&gt;
if not eof then do;&lt;BR /&gt;
 var1 = Total_ER_Calls + var1;&lt;BR /&gt;
 var2 = var2 + Total_ER_To_LM;&lt;BR /&gt;
 end;&lt;BR /&gt;
 &lt;BR /&gt;
if last._Date then do; &lt;BR /&gt;
Date= "Grand Total";&lt;BR /&gt;
Total_Calls = var1;&lt;BR /&gt;
Total_LM = var2;&lt;BR /&gt;
end;&lt;BR /&gt;
 &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
would like it to look like this;&lt;BR /&gt;
&lt;BR /&gt;
Date          Total_Calls       Total_LM&lt;BR /&gt;
1/1/2011          10                  5&lt;BR /&gt;
1/2/2011          15                  3&lt;BR /&gt;
grand total       25                  8</description>
      <pubDate>Thu, 26 May 2011 15:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70041#M15169</guid>
      <dc:creator>mick_g</dc:creator>
      <dc:date>2011-05-26T15:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70042#M15170</link>
      <description>Hello Mick_g,&lt;BR /&gt;
&lt;BR /&gt;
Please provide a sample of  your SAMMARY2 dataset to help you.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 26 May 2011 16:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70042#M15170</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-26T16:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70043#M15171</link>
      <description>Summary2  data&lt;BR /&gt;
&lt;BR /&gt;
Date           Total_Calls           Total_LM&lt;BR /&gt;
1/1/2011     10                        5&lt;BR /&gt;
1/2/2011     15                        3&lt;BR /&gt;
1/3/2011     10                        3&lt;BR /&gt;
.......</description>
      <pubDate>Thu, 26 May 2011 16:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70043#M15171</guid>
      <dc:creator>mick_g</dc:creator>
      <dc:date>2011-05-26T16:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70044#M15172</link>
      <description>This is a solution in the form you requested:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  length date $20.;&lt;BR /&gt;
  input Date $ Total_Calls Total_LM;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1/1/2011 10 5&lt;BR /&gt;
1/2/2011 15 3&lt;BR /&gt;
1/3/2011 10 3&lt;BR /&gt;
run;&lt;BR /&gt;
data r (drop=tc tl) re(drop=Total_Calls Total_LM);&lt;BR /&gt;
  set i end=i;&lt;BR /&gt;
  tc+Total_Calls;&lt;BR /&gt;
  tl+Total_LM;&lt;BR /&gt;
  if i then output re;&lt;BR /&gt;
  output r;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set r re (in=e rename=(tc=Total_Calls tl=Total_LM));&lt;BR /&gt;
  if e then date="Grand Total";&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre] &lt;BR /&gt;
I would like to note that you need a report. For this purpose it is better to use proc TABULATE or proc REPORT.&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 26 May 2011 17:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70044#M15172</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-26T17:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70045#M15173</link>
      <description>mick_g - your problem is that you haven't set the eof variable anywhere, so your &lt;BR /&gt;
if not eof then do...&lt;BR /&gt;
block never executes.&lt;BR /&gt;
&lt;BR /&gt;
You need to add end=eof to your set statement</description>
      <pubDate>Thu, 26 May 2011 17:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations/m-p/70045#M15173</guid>
      <dc:creator>DouglasMartin</dc:creator>
      <dc:date>2011-05-26T17:48:17Z</dc:date>
    </item>
  </channel>
</rss>

