<?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: Total and Average in Proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923330#M26543</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input Plant $ P_Volume P_Revenue Revenue;
	informat P_Volume comma12.;
	informat P_Revenue comma12.;
    informat Revenue comma12.2;
	format P_Volume comma12.;
    format P_Revenue comma12.;
    format Revenue comma12.2;
    datalines;
A 448 53955 120.35
B 999 111863 111.95
B 1652 205770 124.54
C 436 57194 131.33
C 1744 197228 113.07
C 1591 188345 118.38
C 1425 191316 134.23
D 434 54753 126.30
I 762 87614 114.99
I 2492 288658 115.82
M 2149 245107 114.05
N 501 64550 128.74
N 880 101787 115.73
R 670 72555 108.32
S 991 113747 114.73
T 877 115802 132.10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 07 Apr 2024 13:12:54 GMT</pubDate>
    <dc:creator>vnreddy</dc:creator>
    <dc:date>2024-04-07T13:12:54Z</dc:date>
    <item>
      <title>Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923313#M26540</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want Total and sum(P_Revenue)/sum(P_Volume) in Total section.&lt;/P&gt;
&lt;P&gt;I was able to do the Total, but for the same in Total row i want to perform sum(P_Revenue)/sum(P_Volume) as Revenue total.&amp;nbsp; I tried to use mean for Revenue column, but i don't want to use mean, if i use mean i am getting a difference in my Total for my Revenue, so i want the calculation to be:&amp;nbsp; Revenue = sum(P_Revenue)/sum(P_Volume)&lt;/P&gt;
&lt;P&gt;Could someone help me how can i so achieve this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=test split="*";
columns Plant P_Volume P_Revenue Revenue ;
    define Plant / group 'Plant';
    define P_Volume / 'Volume' sum ' ' format=comma12.;
    define P_Revenue / 'P_Revenue' sum ' ' format=comma12. style(column)=[backgroundcolor=#F2F2F2 tagattr="FORMAT:##,##0;(##,##0)"];
	define Revenue / 'Revenue' format=comma12.2 style(column)=[backgroundcolor=#F2F2F2 tagattr="FORMAT:##,##0;(##,##0)"];
	rbreak after / summarize
        style(summary) = {font_weight=bold};
    compute after ;
        Plant = "Total";
    endcomp;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my current output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnreddy_0-1712458615579.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95275i2057A98632CBE7ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnreddy_0-1712458615579.png" alt="vnreddy_0-1712458615579.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnreddy_1-1712458750661.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95276i231659A67AAEC4CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnreddy_1-1712458750661.png" alt="vnreddy_1-1712458750661.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;vnreddy&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 03:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923313#M26540</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-04-07T03:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923326#M26541</link>
      <description>&lt;P&gt;You need to provide some usable (DATA step with DATALINES) example data, so we get a picture what goes into PROC REPORT.&lt;/P&gt;
&lt;P&gt;Is the dataset already cumulated per plant, or are the sums for each plant calculated in the REPORT procedure?&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 10:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923326#M26541</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-04-07T10:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923328#M26542</link>
      <description>&lt;P&gt;Tables like this are one reason why I do the calculations in PROC SUMMARY and a DATA step, and then use PROC REPORT for simply outputting the results in a layout that I want. I don't ask PROC REPORT to do the calculations. I feel I am already very very very familiar with doing these calculations in PROC SUMMARY and/or a DATA step, it will take me 4.73 seconds to get it right. On the other hand, this certainly can be done all in PROC REPORT, but I am not as familiar with that "language" and it might take me 10 minutes of trial and error to get this right in PROC REPORT.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 11:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923328#M26542</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-07T11:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923330#M26543</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input Plant $ P_Volume P_Revenue Revenue;
	informat P_Volume comma12.;
	informat P_Revenue comma12.;
    informat Revenue comma12.2;
	format P_Volume comma12.;
    format P_Revenue comma12.;
    format Revenue comma12.2;
    datalines;
A 448 53955 120.35
B 999 111863 111.95
B 1652 205770 124.54
C 436 57194 131.33
C 1744 197228 113.07
C 1591 188345 118.38
C 1425 191316 134.23
D 434 54753 126.30
I 762 87614 114.99
I 2492 288658 115.82
M 2149 245107 114.05
N 501 64550 128.74
N 880 101787 115.73
R 670 72555 108.32
S 991 113747 114.73
T 877 115802 132.10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Apr 2024 13:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923330#M26543</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-04-07T13:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923331#M26544</link>
      <description>&lt;P&gt;I will try in proc summary&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 13:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923331#M26544</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-04-07T13:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923333#M26545</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test;
	var p_volume p_revenue;
	output out=_test_sums_ sum=;
run;
proc format;
    value $plantf 'ZZZ'='Total';
run;
data report;
    set test _test_sums_;
    if missing(plant) then plant='ZZZ';
    revenue=p_revenue/p_volume;
    format plant $plantf.;
run;
	
proc report data=report;
    columns plant p_volume p_revenue revenue;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Apr 2024 14:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923333#M26545</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-07T14:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923334#M26546</link>
      <description>&lt;P&gt;First of all, don't DEFINE plant as GROUP if you want the observations to stay separate. DEFINE it as DISPLAY.&lt;/P&gt;
&lt;P&gt;Next, use the MEAN statistic to automatically calculate the average; also consider the WEIGHT= option.&lt;/P&gt;
&lt;P&gt;Or calculate the value in the COMPUTE AFTER block.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 14:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923334#M26546</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-04-07T14:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923336#M26547</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 14:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923336#M26547</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-04-07T14:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923359#M26548</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Once you post some data by sas code, that make things easy to code.
And you could make it happen in ONE proc report.
*/
data test;
    input Plant $ P_Volume P_Revenue Revenue;
	informat P_Volume comma12.;
	informat P_Revenue comma12.;
    informat Revenue comma12.2;
	format P_Volume comma12.;
    format P_Revenue comma12.;
    format Revenue comma12.2;
    datalines;
A 448 53955 120.35
B 999 111863 111.95
B 1652 205770 124.54
C 436 57194 131.33
C 1744 197228 113.07
C 1591 188345 118.38
C 1425 191316 134.23
D 434 54753 126.30
I 762 87614 114.99
I 2492 288658 115.82
M 2149 245107 114.05
N 501 64550 128.74
N 880 101787 115.73
R 670 72555 108.32
S 991 113747 114.73
T 877 115802 132.10
;
run;

proc report data=test split="*" nowd ;
columns Plant P_Volume P_Revenue Revenue ;
    define Plant / group 'Plant';
    define P_Volume / 'Volume' sum ' ' format=comma12.;
    define P_Revenue / 'P_Revenue' sum ' ' format=comma12. style(column)=[backgroundcolor=#F2F2F2 tagattr="FORMAT:##,##0;(##,##0)"];
	define Revenue / 'Revenue' format=comma12.2 style(column)=[backgroundcolor=#F2F2F2 tagattr="FORMAT:##,##0;(##,##0)"];
	rbreak after / summarize
        style(summary) = {font_weight=bold};
    compute after ;
        Plant = "Total"; Revenue.sum=P_Revenue.sum/P_Volume.sum;
    endcomp;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1712543468867.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95288iB45DCDB82613B367/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1712543468867.png" alt="Ksharp_0-1712543468867.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 02:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923359#M26548</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-04-08T02:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923386#M26549</link>
      <description>&lt;P&gt;I had a feeling that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; would jump in and provide an answer. I knew it isn't hard to do in PROC REPORT, but its still easier (to me, at least) doing the math in PROC SUMMARY/DATA step. But the good news is that there are many ways to do things in SAS.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 11:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923386#M26549</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-08T11:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Total and Average in Proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923437#M26550</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; As others have stated, getting a sample of your input data file would be good. As it stands, now, the structure of your original data is going to determine how you generate the report you want. Here's why:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1712593949873.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95302i9F2DE333FB0BC333/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1712593949873.png" alt="Cynthia_sas_0-1712593949873.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; With your current usage of GROUP for the PLANT variable, I would expect to see only 1 row for each unique value of PLANT, and this is what we see. In your desired output, you show multiple rows for PLANT B, C and N -- this is the type of report I would expect either if the usage of PLANT was ORDER or DISPLAY. Without seeing the input data for your WORK.TEST file, there's no way to "guess" the structure. I do not see any statistic or COMPUTE block for the REVENUE variable, so I uncertain whether you are calculating a value for REVENUE or just altering a value that is already in the data. At any rate, without data to test with your code, it is hard to make a constructive suggestion.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 16:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Total-and-Average-in-Proc-report/m-p/923437#M26550</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-04-08T16:36:51Z</dc:date>
    </item>
  </channel>
</rss>

