<?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 trying to sum a field in proc report-pdf in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5390#M2175</link>
    <description>I need to sum on one field in a report.  I have tried a lot of different things in the code below and I am getting no summing at all.  The only field I need a sum is “define perc/display'Percent'“&lt;BR /&gt;
&lt;BR /&gt;
I do not need a sum on count and or any of the other fields.&lt;BR /&gt;
&lt;BR /&gt;
I seem to be getting a line for the sum to go on with the contract number repeated, but instead of repeating the contract number I would&lt;BR /&gt;
Like a label called "sub total" and than a space before the next contract number.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help me out in working thru my problem of not knowing how to do this? &lt;BR /&gt;
 &lt;BR /&gt;
I am using SAS 9.1.  Any help you can send me would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ods pdf file='d:\greg1\CLEAN9.pdf';&lt;BR /&gt;
   &lt;BR /&gt;
&lt;BR /&gt;
proc report data=clean9 nowd headline headskip;&lt;BR /&gt;
&lt;BR /&gt;
 column cont_id prj_nbr count perc datevar;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
define  cont_id / group  'Contract'; &lt;BR /&gt;
&lt;BR /&gt;
define prj_nbr / display 'des number';&lt;BR /&gt;
&lt;BR /&gt;
define count / display 'Number of Vouchers'  ; &lt;BR /&gt;
&lt;BR /&gt;
define perc/display'Percent'; &lt;BR /&gt;
&lt;BR /&gt;
define datevar/display'Last Voucher Date';       &lt;BR /&gt;
&lt;BR /&gt;
BREAK  AFTER cont_id / SUMMARIZE DUL DOL ;&lt;BR /&gt;
&lt;BR /&gt;
rbreak after / summarize; &lt;BR /&gt;
&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
ODS PDF CLOSE;</description>
    <pubDate>Wed, 07 Nov 2007 14:02:52 GMT</pubDate>
    <dc:creator>GregINGov</dc:creator>
    <dc:date>2007-11-07T14:02:52Z</dc:date>
    <item>
      <title>trying to sum a field in proc report-pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5390#M2175</link>
      <description>I need to sum on one field in a report.  I have tried a lot of different things in the code below and I am getting no summing at all.  The only field I need a sum is “define perc/display'Percent'“&lt;BR /&gt;
&lt;BR /&gt;
I do not need a sum on count and or any of the other fields.&lt;BR /&gt;
&lt;BR /&gt;
I seem to be getting a line for the sum to go on with the contract number repeated, but instead of repeating the contract number I would&lt;BR /&gt;
Like a label called "sub total" and than a space before the next contract number.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help me out in working thru my problem of not knowing how to do this? &lt;BR /&gt;
 &lt;BR /&gt;
I am using SAS 9.1.  Any help you can send me would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ods pdf file='d:\greg1\CLEAN9.pdf';&lt;BR /&gt;
   &lt;BR /&gt;
&lt;BR /&gt;
proc report data=clean9 nowd headline headskip;&lt;BR /&gt;
&lt;BR /&gt;
 column cont_id prj_nbr count perc datevar;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
define  cont_id / group  'Contract'; &lt;BR /&gt;
&lt;BR /&gt;
define prj_nbr / display 'des number';&lt;BR /&gt;
&lt;BR /&gt;
define count / display 'Number of Vouchers'  ; &lt;BR /&gt;
&lt;BR /&gt;
define perc/display'Percent'; &lt;BR /&gt;
&lt;BR /&gt;
define datevar/display'Last Voucher Date';       &lt;BR /&gt;
&lt;BR /&gt;
BREAK  AFTER cont_id / SUMMARIZE DUL DOL ;&lt;BR /&gt;
&lt;BR /&gt;
rbreak after / summarize; &lt;BR /&gt;
&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
ODS PDF CLOSE;</description>
      <pubDate>Wed, 07 Nov 2007 14:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5390#M2175</guid>
      <dc:creator>GregINGov</dc:creator>
      <dc:date>2007-11-07T14:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: trying to sum a field in proc report-pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5391#M2176</link>
      <description>Hi:&lt;BR /&gt;
  In order for PROC REPORT to give you a SUM, you need to tell it (in your DEFINE statement) to use a variable as an analysis variable. You have this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
define perc/display 'Percent'; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
When PROC REPORT sees the usage of DISPLAY, it explicitly does NOT give you a SUM on that column. So you need to change the usage from DISPLAY to ONE of these DEFINE statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
define perc/analysis 'Percent'; &lt;BR /&gt;
define perc/analysis sum 'Percent'; &lt;BR /&gt;
define perc/sum 'Percent'; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Any one of those versions of the statement would work for you.&lt;BR /&gt;
1 -- because the default statistic for the analysis usage is SUM&lt;BR /&gt;
2 -- because you are explicitly specifying the analysis usage and the statistic&lt;BR /&gt;
3 -- because when you specify a statistic, the usage of analysis is assumed&lt;BR /&gt;
&lt;BR /&gt;
In order to "rename" the contract id at the break, a compute block will essentially take what's in the field at the break and rename it (this code assumes that contract id is a character variable -- you'd have to do something different if it was a numeric variable):&lt;BR /&gt;
[pre]&lt;BR /&gt;
compute after cont_id;&lt;BR /&gt;
   cont_id = 'Subtotal';&lt;BR /&gt;
endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
This compute block can go anywhere in your PROC REPORT program. For readability purposes, I recommend putting it under the BREAK statement, so you know that a COMPUTE block will execute at the BREAK. &lt;BR /&gt;
&lt;BR /&gt;
If you were sending output to the LISTING window, then you could add the SKIP option to your BREAK statement to get a skipped line after the summarized report row:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
BREAK AFTER cont_id / SUMMARIZE DUL DOL SKIP ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
However, SKIP is ignored for ODS HTML, RTF and PDF, so you have to make one more change to your COMPUTE block -- by adding a LINE statement to insert a blank line after the summary line:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
compute after cont_id;&lt;BR /&gt;
   cont_id = 'Subtotal';&lt;BR /&gt;
   line ' ';&lt;BR /&gt;
endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
For more help with PROC REPORT syntax, the on-line documentation and help files are very thorough and have some good examples. Or, you can contact Tech Support for help with your particular data and specific processing need.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 07 Nov 2007 15:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5391#M2176</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-11-07T15:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: trying to sum a field in proc report-pdf</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5392#M2177</link>
      <description>Thanks Cynthia! What you told me is working great.</description>
      <pubDate>Wed, 07 Nov 2007 16:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/trying-to-sum-a-field-in-proc-report-pdf/m-p/5392#M2177</guid>
      <dc:creator>GregINGov</dc:creator>
      <dc:date>2007-11-07T16:22:00Z</dc:date>
    </item>
  </channel>
</rss>

