<?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 proc report summarize in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-summarize/m-p/66439#M7705</link>
    <description>Hello all,&lt;BR /&gt;
     I am using proc report for one of the reports and I am not sure on how to summarize the results. I have 5 numeric fields and a flag, I would like to show a total row (summarized row) for all the numeric fields when the flag is no, but I want to only summarize 3 columns when the flag is yes&lt;BR /&gt;
&lt;BR /&gt;
I am not sure on how to do that, if I use "display" on the numeric columns then they are never summarized, can anyone tell me is I can summarize numeric fields based on a flag.&lt;BR /&gt;
Here is an example&lt;BR /&gt;
&lt;BR /&gt;
flag   field1     field2        field3        field4           field5&lt;BR /&gt;
n        100         200        300           400            500&lt;BR /&gt;
n         10            20          30            40             50&lt;BR /&gt;
y         101         201         301          401          501&lt;BR /&gt;
y          11          21           31            41            51&lt;BR /&gt;
&lt;BR /&gt;
when the report runs I want the output tobe&lt;BR /&gt;
&lt;BR /&gt;
n           110            220          330         440        550&lt;BR /&gt;
y                                             331         441      &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank You&lt;BR /&gt;
Shri</description>
    <pubDate>Tue, 17 May 2011 14:50:08 GMT</pubDate>
    <dc:creator>sks</dc:creator>
    <dc:date>2011-05-17T14:50:08Z</dc:date>
    <item>
      <title>proc report summarize</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-summarize/m-p/66439#M7705</link>
      <description>Hello all,&lt;BR /&gt;
     I am using proc report for one of the reports and I am not sure on how to summarize the results. I have 5 numeric fields and a flag, I would like to show a total row (summarized row) for all the numeric fields when the flag is no, but I want to only summarize 3 columns when the flag is yes&lt;BR /&gt;
&lt;BR /&gt;
I am not sure on how to do that, if I use "display" on the numeric columns then they are never summarized, can anyone tell me is I can summarize numeric fields based on a flag.&lt;BR /&gt;
Here is an example&lt;BR /&gt;
&lt;BR /&gt;
flag   field1     field2        field3        field4           field5&lt;BR /&gt;
n        100         200        300           400            500&lt;BR /&gt;
n         10            20          30            40             50&lt;BR /&gt;
y         101         201         301          401          501&lt;BR /&gt;
y          11          21           31            41            51&lt;BR /&gt;
&lt;BR /&gt;
when the report runs I want the output tobe&lt;BR /&gt;
&lt;BR /&gt;
n           110            220          330         440        550&lt;BR /&gt;
y                                             331         441      &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank You&lt;BR /&gt;
Shri</description>
      <pubDate>Tue, 17 May 2011 14:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-summarize/m-p/66439#M7705</guid>
      <dc:creator>sks</dc:creator>
      <dc:date>2011-05-17T14:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc report summarize</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-summarize/m-p/66440#M7706</link>
      <description>Hi:&lt;BR /&gt;
  I am confused by your data and your results. You say that you want to summarize only 3 columns for the Y values, however, you only show 2 columns in your desired output. Also, according to my calculator, your summary numbers are "off". &lt;BR /&gt;
&lt;BR /&gt;
  For example just looking at what I think the summary should be, based on your posted data:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Sum of N:&lt;BR /&gt;
                     &lt;BR /&gt;
flag field1 field2 field3 field4 field5&lt;BR /&gt;
n       100    200    300    400    500&lt;BR /&gt;
n        10     20     30     40     50&lt;BR /&gt;
        110    220    330    440    550&lt;BR /&gt;
    &lt;BR /&gt;
          &lt;BR /&gt;
Sum of Y:&lt;BR /&gt;
               &lt;BR /&gt;
flag field1 field2 field3 field4 field5&lt;BR /&gt;
y       101    201    301    401    501&lt;BR /&gt;
y        11     21     31     41     51&lt;BR /&gt;
        112    222    332    442    552&lt;BR /&gt;
[/pre]&lt;BR /&gt;
   &lt;BR /&gt;
Also, it was not clear to me which of the 5 columns you wanted to "suppress" for the Y value.&lt;BR /&gt;
&lt;BR /&gt;
DISPLAY would be the wrong usage choice for your FIELD variables. You will need a usage of SUM. PROC REPORT, by default, will summarize ALL of your columns with a usage of SUM. This is OK, though, because PROC REPORT will also allow you to alter what is shown on the summary line (although not many people use this feature).&lt;BR /&gt;
 &lt;BR /&gt;
If, for example, you wanted to suppress the value for FIELD1, then you could do this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  compute field1;&lt;BR /&gt;
    if flag = 'y' then do;&lt;BR /&gt;
       field1.sum=.;&lt;BR /&gt;
    end;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
If, on the other hand, you wanted to change the value of FIELD1 to 999999, then you could do that too:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  compute field1;&lt;BR /&gt;
    if flag = 'y' then do;&lt;BR /&gt;
       field1.sum=999999;&lt;BR /&gt;
    end;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                            &lt;BR /&gt;
 PROC REPORT is very flexible. What you have to understand is that if you want to suppress certain columns from showing on the summarized rows, you have to allow PROC REPORT to do the summary by defining your FLAG item as a GROUP usage and then defining the various FIELD items as a usage of SUM.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 18 May 2011 00:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-summarize/m-p/66440#M7706</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-05-18T00:24:03Z</dc:date>
    </item>
  </channel>
</rss>

