<?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: Need to add a column with row totals for all rows, including computed ones in PROC Report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934533#M367495</link>
    <description>That did it, thanks.  For the totals I was referring to the original Total and Grand Total rows, which were summed with this.</description>
    <pubDate>Wed, 03 Jul 2024 11:40:29 GMT</pubDate>
    <dc:creator>RandoDando</dc:creator>
    <dc:date>2024-07-03T11:40:29Z</dc:date>
    <item>
      <title>Need to add a column with row totals for all rows, including computed ones in PROC Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934441#M367454</link>
      <description>&lt;P&gt;I have this code using the across and analysis functions.&amp;nbsp; I want to add 1 column on the far right side which has the row totals going across, including those for the computed Totals.&amp;nbsp; &amp;nbsp;If you are wondering about the single letter coding, I used those to re-word some values and found letters to be easier to manage while assigning the visible text in Proc Format.&amp;nbsp; No numbers because numeric format interfered with the Total labels.&amp;nbsp; &amp;nbsp;If I have to change something, then I know exactly where to go.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=TEAM_SUMMARY nowd  ;
columns Team Activity Month, cnt ;
define Team/ group order=data;
define Activity/group "Activity" format=$Acty. order=internal;
define Month/across "Month in Play" order=data f=$Month.;
define cnt/analysis "" f=comma18.0;


compute Activity;

if Activity= 'J' then do;
	 call define(_row_, "style", "style=[foreground=Red]");
	 end;
if Activity = 'K' then do;
	 call define(_row_, "style", "style=[foreground=Green]");
	 end;

endcomp;

break after Team/summarize style=[foreground=black just=r font_weight=bold];

rbreak after /summarize style=Header[background=lightgreen just=c];

compute before Team/style=[background=light grey];
line  ' ';
endcomp;

compute after Team;
Activity = 'Team Total';
endcomp;

compute after;
Activity = 'Grand Total';
endcomp;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 17:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934441#M367454</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2024-07-02T17:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to add a column with row totals for all rows, including computed ones in PROC Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934454#M367460</link>
      <description>&lt;P&gt;Hi: Without data, it is hard to tweak your code. However, using an alias, it should be fairly easy to get the row totals on the right side of the report. I'm not sure I understand what you mean when you say: "including those for Computed totals". I don't see any computed totals. Do you mean the CNT values?&lt;BR /&gt;Cynthia&lt;/P&gt;
&lt;P&gt;Here's an example of using an Alias. Since you did not provide data, I had to make some fake data for a small selection of months, just enough to get the general idea:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1719947075838.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98090i4565D70772265A9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1719947075838.png" alt="Cynthia_sas_0-1719947075838.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is the code and result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1719947098876.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98091iBC552CE04C849004/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1719947098876.png" alt="Cynthia_sas_1-1719947098876.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The final column on the right side was the result of using an ALIAS&amp;nbsp; (Cnt=ColTot). Using an alias essentially allows me to use CNT 2 different ways -- the first way it is UNDER the MONTH ACROSS item and the second way, it is being used without regard to the ACROSS item and it is referred to by the ALIAS name in the DEFINE statement.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 19:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934454#M367460</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-07-02T19:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need to add a column with row totals for all rows, including computed ones in PROC Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934533#M367495</link>
      <description>That did it, thanks.  For the totals I was referring to the original Total and Grand Total rows, which were summed with this.</description>
      <pubDate>Wed, 03 Jul 2024 11:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-add-a-column-with-row-totals-for-all-rows-including/m-p/934533#M367495</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2024-07-03T11:40:29Z</dc:date>
    </item>
  </channel>
</rss>

