<?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: How to get subtotal/grand total right in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60851#M17262</link>
    <description>You need to do some of the work. &lt;BR /&gt;
Please boil the problem down a bit: provide less code if possible, some data (or use sashelp tables), and explain what you think is wrong.</description>
    <pubDate>Tue, 04 Aug 2009 23:12:31 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2009-08-04T23:12:31Z</dc:date>
    <item>
      <title>How to get subtotal/grand total right</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60849#M17260</link>
      <description>I am trying to get subtotals based on ffp_type, but just couldn't get it right. &lt;BR /&gt;
&lt;BR /&gt;
Here is my code:&lt;BR /&gt;
&lt;BR /&gt;
 %macro createfile(board_num);   /*to create board files repeatedly according to the board number*/&lt;BR /&gt;
 %do i = 1 %to &amp;amp;board_num;&lt;BR /&gt;
 data bd&amp;amp;&amp;amp;bdnum&amp;amp;i;&lt;BR /&gt;
   retain reg arr bcp 0;&lt;BR /&gt;
   set final3;&lt;BR /&gt;
   if w = "&amp;amp;&amp;amp;bdnum&amp;amp;i";&lt;BR /&gt;
 run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
options pageno = 1 nodate linesize = 80;&lt;BR /&gt;
&lt;BR /&gt;
 proc report data = bd&amp;amp;&amp;amp;bdnum&amp;amp;i nowd split = '*' missing;&lt;BR /&gt;
   column company fy ffp_type ffp hsreimb hsreimb=compreg hsreimb=comparr hsreimb=compbcp;&lt;BR /&gt;
&lt;BR /&gt;
   define company     /group 'Company' format = $char10.;&lt;BR /&gt;
   define fy          /group 'FY';&lt;BR /&gt;
   define ffp_type    /group 'FFP Type' order=internal format = $ffptype.;&lt;BR /&gt;
   define ffp         /group 'FFP %';&lt;BR /&gt;
   define hsreimb     /analysis 'Total*Reimb.' sum format = comma10.2 ;&lt;BR /&gt;
   define compreg     /sum noprint;&lt;BR /&gt;
   define comparr     /sum noprint;&lt;BR /&gt;
   define compbcp     /sum noprint;&lt;BR /&gt;
&lt;BR /&gt;
   compute before company;&lt;BR /&gt;
     comptot = 0; compreg =0; comparr = 0; compbcp =0;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
   compute before fy;&lt;BR /&gt;
     regsum = 0; arrsum = 0; bcpsum = 0; fytot = hsreimb.sum;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
   compute after ffp_type;&lt;BR /&gt;
      if ffp_type = '1' then do;&lt;BR /&gt;
      regsum = hsreimb.sum; compreg = +hsreimb.sum; end;&lt;BR /&gt;
      else if ffp_type = '2' then do;&lt;BR /&gt;
      arrsum = hsreimb.sum; comparr = +hsreimb.sum; end;&lt;BR /&gt;
      else do;&lt;BR /&gt;
      bcpsum = hsreimb.sum; compbcp = +hsreimb.sum; end;&lt;BR /&gt;
&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
   compute after fy;&lt;BR /&gt;
      line ' ';&lt;BR /&gt;
      line 'Subtotal for Regular'    @54 regsum comma10.2;&lt;BR /&gt;
      line 'Subtotal for ARRA'       @54 arrsum comma10.2;&lt;BR /&gt;
      line 'Subtotal for BCCP_CHIP'  @54 bcpsum comma10.2;&lt;BR /&gt;
      line 'SFY Total '              @54 fytot comma10.2;&lt;BR /&gt;
      line ' ';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
   compute after company;&lt;BR /&gt;
     comptot = hsreimb.sum;&lt;BR /&gt;
     line 'Company Reg Total' @54 compreg comma10.2;&lt;BR /&gt;
     line 'Company Arr Total' @54 comparr comma10.2;&lt;BR /&gt;
     line 'Company Total' @54 comptot comma10.2;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 title1 'Program ID: mcd_manual_reversal                          page: ' ;&lt;BR /&gt;
&lt;BR /&gt;
 %end;&lt;BR /&gt;
%mend createfile;&lt;BR /&gt;
&lt;BR /&gt;
%createfile(&amp;amp;board_cnt);&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Here is my result (partial)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                                                          Total&lt;BR /&gt;
                 Company     FY    FFP Type   FFP %      Reimb.&lt;BR /&gt;
                 XXXX       2009  REGULAR    62.14    1,539.15&lt;BR /&gt;
                                   ARRA       71.29      543.98&lt;BR /&gt;
&lt;BR /&gt;
Subtotal for Regular                                   1,539.15&lt;BR /&gt;
Subtotal for ARRA                                        543.98&lt;BR /&gt;
Subtotal for BCCP_CHIP                                     0.00&lt;BR /&gt;
SFY Total                                              2,083.13&lt;BR /&gt;
&lt;BR /&gt;
Company Reg Total                                      2,083.13&lt;BR /&gt;
Company Arr Total                                      2,083.13&lt;BR /&gt;
Company Total                                          2,083.13&lt;BR /&gt;
        Program ID: mcd_manual_reversal                          page:         1&lt;BR /&gt;
&lt;BR /&gt;
                                                          Total&lt;BR /&gt;
                 Company     FY    FFP Type   FFP %      Reimb.&lt;BR /&gt;
                 YYYYB        2009  REGULAR    62.14   34,558.03&lt;BR /&gt;
                                   ARRA       71.29   10,320.02&lt;BR /&gt;
                                   BCCP_CHIP  73.5     5,623.03&lt;BR /&gt;
&lt;BR /&gt;
Subtotal for Regular                                  34,558.03&lt;BR /&gt;
Subtotal for ARRA                                     10,320.02&lt;BR /&gt;
Subtotal for BCCP_CHIP                                 5,623.03&lt;BR /&gt;
SFY Total                                             50,501.08&lt;BR /&gt;
&lt;BR /&gt;
Company Reg Total                                     50,501.08&lt;BR /&gt;
Company Arr Total                                     50,501.08&lt;BR /&gt;
Company Total                                         50,501.08&lt;BR /&gt;
&lt;BR /&gt;
Can anybody debug my program? I really appreciate it!</description>
      <pubDate>Fri, 31 Jul 2009 14:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60849#M17260</guid>
      <dc:creator>odmhx</dc:creator>
      <dc:date>2009-07-31T14:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subtotal/grand total right</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60850#M17261</link>
      <description>The output in my previous post doesn't align right. Here is another try:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
        Program ID: mcd_manual_reversal                          page:         1&lt;BR /&gt;
&lt;BR /&gt;
                                                                              Total&lt;BR /&gt;
                 Company     FY    FFP Type    FFP %      Reimb.&lt;BR /&gt;
                 XXXXX        2009  REGULAR    62.14    1,539.15&lt;BR /&gt;
                                           ARRA          71.29      543.98&lt;BR /&gt;
&lt;BR /&gt;
Subtotal for Regular                                             1,539.15&lt;BR /&gt;
Subtotal for ARRA                                                  543.98&lt;BR /&gt;
Subtotal for BCCP_CHIP                                            0.00&lt;BR /&gt;
SFY Total                                                           2,083.13&lt;BR /&gt;
&lt;BR /&gt;
Company Reg Total                                             2,083.13&lt;BR /&gt;
Company Arr Total                                               2,083.13&lt;BR /&gt;
Company Total                                                    2,083.13&lt;BR /&gt;
&lt;BR /&gt;
        Program ID: mcd_manual_reversal                          page:         1&lt;BR /&gt;
&lt;BR /&gt;
                                                                              Total&lt;BR /&gt;
                 Company     FY    FFP Type    FFP %      Reimb.&lt;BR /&gt;
                 YYYYY       2009  REGULAR   62.14     34,558.03&lt;BR /&gt;
                                            ARRA          71.29     10,320.02&lt;BR /&gt;
                                            BCCP_CHIP  73.5       5,623.03&lt;BR /&gt;
&lt;BR /&gt;
Subtotal for Regular                                                34,558.03&lt;BR /&gt;
Subtotal for ARRA                                                  10,320.02&lt;BR /&gt;
Subtotal for BCCP_CHIP                                          5,623.03&lt;BR /&gt;
SFY Total                                                             50,501.08&lt;BR /&gt;
&lt;BR /&gt;
Company Reg Total                                               50,501.08&lt;BR /&gt;
Company Arr Total                                                 50,501.08&lt;BR /&gt;
Company Total                                                      50,501.08</description>
      <pubDate>Fri, 31 Jul 2009 15:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60850#M17261</guid>
      <dc:creator>odmhx</dc:creator>
      <dc:date>2009-07-31T15:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subtotal/grand total right</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60851#M17262</link>
      <description>You need to do some of the work. &lt;BR /&gt;
Please boil the problem down a bit: provide less code if possible, some data (or use sashelp tables), and explain what you think is wrong.</description>
      <pubDate>Tue, 04 Aug 2009 23:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-subtotal-grand-total-right/m-p/60851#M17262</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-08-04T23:12:31Z</dc:date>
    </item>
  </channel>
</rss>

