<?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: Proc Report sum and average in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587096#M75854</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc report.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32319i1FFCE65D94B745D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc report.png" alt="proc report.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 08 Sep 2019 18:29:34 GMT</pubDate>
    <dc:creator>sameer112217</dc:creator>
    <dc:date>2019-09-08T18:29:34Z</dc:date>
    <item>
      <title>Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586991#M75842</link>
      <description>&lt;P&gt;Hello I am writing a code but here is my difficulty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample;&lt;BR /&gt;length state $50;&lt;BR /&gt;input state$ city$ product$ selling_price revenue;&lt;BR /&gt;datalines;&lt;BR /&gt;Maharashtra Mumbai Soap 100 10&lt;BR /&gt;Maharashtra Mumbai Shampoo 200 20&lt;BR /&gt;Maharashtra Pune Soap 100 10&lt;BR /&gt;Maharashtra Pune Shampoo 200 20&lt;BR /&gt;Gujrat Baroda Come 100 2&lt;BR /&gt;Gujrat Baroda Pin 300 40&lt;BR /&gt;Gujrat Surat Come 100 2&lt;BR /&gt;Gujrat Surat Pin 400 10&lt;BR /&gt;Punjab Amritsar Pencil 200 3&lt;BR /&gt;Punjab Chandigarh Rubber 20 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=sample;&lt;BR /&gt;run;&lt;BR /&gt;data sample;&lt;BR /&gt;length state $50;&lt;BR /&gt;length zone $100;&lt;BR /&gt;set sample;&lt;BR /&gt;if state="Maharashtra" then target=500;&lt;BR /&gt;if state="Gujrat" then target=400;&lt;BR /&gt;if state="Punjab" then target=200;&lt;BR /&gt;if state="Maharashtra" then Zone="AB";&lt;BR /&gt;if state="Gujrat" then Zone="BC/MLA";&lt;BR /&gt;if state="Punjab" then Zone="BC/MLA";&lt;BR /&gt;run;&lt;BR /&gt;proc print data=sample;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc report data=sample;&lt;BR /&gt;column zone state selling_price target diff;&lt;BR /&gt;define zone/group;&lt;BR /&gt;define state/group;&lt;BR /&gt;define selling_price/sum;&lt;BR /&gt;define revenue/sum;&lt;BR /&gt;define target/mean;&lt;BR /&gt;define diff/computed;&lt;BR /&gt;compute diff;&lt;BR /&gt;diff=selling_price.sum-target.sum;&lt;BR /&gt;endcomp;&lt;/P&gt;&lt;P&gt;compute after zone;&lt;BR /&gt;zone=catx('',propcase(zone),'Subtotal');&lt;BR /&gt;line '';&lt;BR /&gt;endcomp;&lt;/P&gt;&lt;P&gt;/*break after state/summarize;*/&lt;BR /&gt;break after zone/summarize;&lt;BR /&gt;rbrEAK AFTER /SUMMARIzE DOL DUL;&lt;/P&gt;&lt;P&gt;compute after;&lt;BR /&gt;state= 'Total';&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting below attached results. For Target I used target.mean in the diff in compute but I need sum in subtotal and total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc report.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32313iA8A1324E5BEFA930/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc report.png" alt="proc report.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Sep 2019 18:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586991#M75842</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2019-09-07T18:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586994#M75843</link>
      <description>&lt;P&gt;The subtotal and total I need is sum of the target. The target column numbers I had to add it in the above code, hence I had to use mean/average but while doing total I need the sum. Is there any way to do it.&amp;nbsp; Also the zone subtotal using catx is showing shorter length. is there any way to increase it&lt;/P&gt;</description>
      <pubDate>Sat, 07 Sep 2019 18:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586994#M75843</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2019-09-07T18:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586998#M75844</link>
      <description>&lt;P&gt;Please provide the actual code that you used that produced this report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code you provided is not the actual code used, as it produces an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; WARNING: revenue is not in the report definition.
 ERROR: The variable type of TARGET.SUM is invalid in this context.
 NOTE: The preceding messages refer to the COMPUTE block for diff.
 NOTE: Will not run due to compilation errors.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 10 observations read from the data set WORK.SAMPLE.
 NOTE: PROCEDURE REPORT used (Total process time):
       real time           0.10 seconds
       cpu time            0.04 seconds&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Sep 2019 21:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/586998#M75844</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-07T21:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587063#M75849</link>
      <description>&lt;P&gt;Hello paigemiller, here i remove it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc report data=sample;&lt;BR /&gt;column zone state selling_price target diff;&lt;BR /&gt;define zone/group;&lt;BR /&gt;define state/group;&lt;BR /&gt;define selling_price/sum;&lt;BR /&gt;define target/mean;&lt;BR /&gt;define diff/computed;&lt;BR /&gt;compute diff;&lt;BR /&gt;diff=selling_price.sum-target.mean;&lt;BR /&gt;endcomp;&lt;/P&gt;&lt;P&gt;compute after zone;&lt;BR /&gt;zone=catx('',propcase(zone),'Subtotal');&lt;BR /&gt;line '';&lt;BR /&gt;endcomp;&lt;/P&gt;&lt;P&gt;/*break after state/summarize;*/&lt;BR /&gt;break after zone/summarize;&lt;BR /&gt;rbrEAK AFTER /SUMMARIzE DOL DUL;&lt;/P&gt;&lt;P&gt;compute after;&lt;BR /&gt;state= 'Total';&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 10:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587063#M75849</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2019-09-08T10:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587076#M75853</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello paigemiller, here i remove it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc report data=sample;&lt;BR /&gt;column zone state selling_price target diff;&lt;BR /&gt;define zone/group;&lt;BR /&gt;define state/group;&lt;BR /&gt;define selling_price/sum;&lt;BR /&gt;define target/&lt;FONT color="#FF0000"&gt;mean&lt;/FONT&gt;;&lt;BR /&gt;define diff/computed;&lt;BR /&gt;compute diff;&lt;BR /&gt;diff=selling_price.sum-target.&lt;FONT color="#FF0000"&gt;mean&lt;/FONT&gt;;&lt;BR /&gt;endcomp;&lt;/P&gt;
&lt;P&gt;compute after zone;&lt;BR /&gt;zone=catx('',propcase(zone),'Subtotal');&lt;BR /&gt;line '';&lt;BR /&gt;endcomp;&lt;/P&gt;
&lt;P&gt;/*break after state/summarize;*/&lt;BR /&gt;break after zone/summarize;&lt;BR /&gt;rbrEAK AFTER /SUMMARIzE DOL DUL;&lt;/P&gt;
&lt;P&gt;compute after;&lt;BR /&gt;state= 'Total';&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your code is asking for means instead of sums. So SAS gives you what you asked for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if that's not what you want, then you'd have to modify the code to get what you want. Can you show us (or tell us) the numbers you want to see, and how they are calculated?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 14:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587076#M75853</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-08T14:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587096#M75854</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc report.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32319i1FFCE65D94B745D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc report.png" alt="proc report.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 18:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587096#M75854</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2019-09-08T18:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587097#M75855</link>
      <description>&lt;P&gt;i want average of target but sum in the subtotal and total&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 18:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587097#M75855</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2019-09-08T18:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report sum and average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587104#M75860</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i want average of target but sum in the subtotal and total&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have never seen a table where you show the average on some rows and sum for other rows in the same column. This seems like a bad idea to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, I have no idea how you can get PROC REPORT to show average on some rows in the column and sum on other rows in a column. Perhaps someone has a clever solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could certainly create such a table of means and sums using PROC SUMMARY and data steps, so that the table is exactly what you want, and then simply have PROC REPORT display the resulting table.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 21:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Report-sum-and-average/m-p/587104#M75860</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-08T21:02:11Z</dc:date>
    </item>
  </channel>
</rss>

