<?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 Rows above header in PROC REPORT? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66310#M7682</link>
    <description>Suppose I want to create a report using PROC REPORT and the ExcelXP tagset; the report should have data filters and a subtotal at the top.&lt;BR /&gt;
&lt;BR /&gt;
That's straightforward to do if you want only one total:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
ods tagsets.ExcelXP&lt;BR /&gt;
      file='c:\temp\subtotal.xls'&lt;BR /&gt;
         options(&lt;BR /&gt;
            embedded_titles='yes'&lt;BR /&gt;
            row_repeat='4'&lt;BR /&gt;
            frozen_headers='4'&lt;BR /&gt;
            autofilter='all'&lt;BR /&gt;
            orientation='landscape');&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
&lt;BR /&gt;
title 'Excel Subtotal';&lt;BR /&gt;
&lt;BR /&gt;
proc report data=sashelp.prdsale nofs missing nocenter;&lt;BR /&gt;
   where actual &amp;gt;= 500;&lt;BR /&gt;
&lt;BR /&gt;
   column country region product &lt;BR /&gt;
          country=country2 region=region2 product=product2&lt;BR /&gt;
          actual predict n;&lt;BR /&gt;
&lt;BR /&gt;
   define country  / group noprint;&lt;BR /&gt;
   define region   / group noprint;&lt;BR /&gt;
   define product  / group noprint;&lt;BR /&gt;
   define country2 / group;&lt;BR /&gt;
   define region2  / group;&lt;BR /&gt;
   define product2 / group;&lt;BR /&gt;
   define actual   / sum;&lt;BR /&gt;
   define predict  / sum;&lt;BR /&gt;
   define n        / noprint;&lt;BR /&gt;
&lt;BR /&gt;
   compute before _page_;&lt;BR /&gt;
      rows = n + 7;&lt;BR /&gt;
      line '="Total of ACTUAL in selected records: " &amp;amp; text(subtotal(9,r5c4:r' rows z5. 'c4), "$ #,##0.00")';&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.excelxp close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
&lt;BR /&gt;
x 'start c:\temp\subtotal.xls';&lt;BR /&gt;
=====&lt;BR /&gt;
&lt;BR /&gt;
The COMPUTE BEFORE _PAGE_ block lets me write a line above the column headers, and the SUBTOTAL formula returns the sum of the values in column 4 after filtering.&lt;BR /&gt;
&lt;BR /&gt;
But suppose I want to have the total of the ACTUAL column in column 4, and the total of the PREDICT column in column 5; is there a way to do that?  In other words, is there a way to write to a particular column in a COMPUTE BEFORE _PAGE_ block?&lt;BR /&gt;
&lt;BR /&gt;
Also, if I have two LINE statements in the compute block, only the first line is written; is this a bug, or expected behavior (expected by other people, that is)?&lt;BR /&gt;
&lt;BR /&gt;
PS: How do I post code with indentation?</description>
    <pubDate>Wed, 17 Dec 2008 16:55:03 GMT</pubDate>
    <dc:creator>JackHamilton</dc:creator>
    <dc:date>2008-12-17T16:55:03Z</dc:date>
    <item>
      <title>Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66310#M7682</link>
      <description>Suppose I want to create a report using PROC REPORT and the ExcelXP tagset; the report should have data filters and a subtotal at the top.&lt;BR /&gt;
&lt;BR /&gt;
That's straightforward to do if you want only one total:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
ods tagsets.ExcelXP&lt;BR /&gt;
      file='c:\temp\subtotal.xls'&lt;BR /&gt;
         options(&lt;BR /&gt;
            embedded_titles='yes'&lt;BR /&gt;
            row_repeat='4'&lt;BR /&gt;
            frozen_headers='4'&lt;BR /&gt;
            autofilter='all'&lt;BR /&gt;
            orientation='landscape');&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
&lt;BR /&gt;
title 'Excel Subtotal';&lt;BR /&gt;
&lt;BR /&gt;
proc report data=sashelp.prdsale nofs missing nocenter;&lt;BR /&gt;
   where actual &amp;gt;= 500;&lt;BR /&gt;
&lt;BR /&gt;
   column country region product &lt;BR /&gt;
          country=country2 region=region2 product=product2&lt;BR /&gt;
          actual predict n;&lt;BR /&gt;
&lt;BR /&gt;
   define country  / group noprint;&lt;BR /&gt;
   define region   / group noprint;&lt;BR /&gt;
   define product  / group noprint;&lt;BR /&gt;
   define country2 / group;&lt;BR /&gt;
   define region2  / group;&lt;BR /&gt;
   define product2 / group;&lt;BR /&gt;
   define actual   / sum;&lt;BR /&gt;
   define predict  / sum;&lt;BR /&gt;
   define n        / noprint;&lt;BR /&gt;
&lt;BR /&gt;
   compute before _page_;&lt;BR /&gt;
      rows = n + 7;&lt;BR /&gt;
      line '="Total of ACTUAL in selected records: " &amp;amp; text(subtotal(9,r5c4:r' rows z5. 'c4), "$ #,##0.00")';&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.excelxp close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
&lt;BR /&gt;
x 'start c:\temp\subtotal.xls';&lt;BR /&gt;
=====&lt;BR /&gt;
&lt;BR /&gt;
The COMPUTE BEFORE _PAGE_ block lets me write a line above the column headers, and the SUBTOTAL formula returns the sum of the values in column 4 after filtering.&lt;BR /&gt;
&lt;BR /&gt;
But suppose I want to have the total of the ACTUAL column in column 4, and the total of the PREDICT column in column 5; is there a way to do that?  In other words, is there a way to write to a particular column in a COMPUTE BEFORE _PAGE_ block?&lt;BR /&gt;
&lt;BR /&gt;
Also, if I have two LINE statements in the compute block, only the first line is written; is this a bug, or expected behavior (expected by other people, that is)?&lt;BR /&gt;
&lt;BR /&gt;
PS: How do I post code with indentation?</description>
      <pubDate>Wed, 17 Dec 2008 16:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66310#M7682</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2008-12-17T16:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66311#M7683</link>
      <description>Hi, Jack:&lt;BR /&gt;
  [ pre ] and [/ pre ] around your code (only without spaces).&lt;BR /&gt;
&lt;BR /&gt;
Or to put it another way...just like the &amp;lt;pre&amp;gt; and &amp;lt;/pre&amp;gt;, but with square brackets instead of &amp;lt; and &amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
Not sure about the rest of your questions without looking closer at the code.&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 17 Dec 2008 20:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66311#M7683</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-12-17T20:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66312#M7684</link>
      <description>Jack:&lt;BR /&gt;
  Did you notice how the output from the LINE statement spans all the columns at the top of the table? That's because the XML has this instruction caused by the LINE statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="NoteContent" ss:MergeAcross="4"  .......&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
So, there's no way to place numbers in column 4 or column 5 inside the LINE statement because the line is automatically spanning or merging multiple columns.&lt;BR /&gt;
&lt;BR /&gt;
The best I could do was COMPUTE BEFORE and COMPUTE AFTER. Maybe you could assign a formula using TAGATTR. But the thing is that the BREAK BEFORE/COMPUTE BEFORE location is NOT the same as the COMPUTE BEFORE _PAGE_ location and it might not be what you want.&lt;BR /&gt;
 &lt;BR /&gt;
In the code below, I simplified the text in the LINE at the top.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods tagsets.ExcelXP&lt;BR /&gt;
    file='c:\temp\subtotal.xls'&lt;BR /&gt;
    options(&lt;BR /&gt;
    embedded_titles='yes'&lt;BR /&gt;
    row_repeat='4'&lt;BR /&gt;
    frozen_headers='4'&lt;BR /&gt;
    autofilter='all'&lt;BR /&gt;
    orientation='landscape');&lt;BR /&gt;
                        &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
               &lt;BR /&gt;
title 'Excel Subtotal';&lt;BR /&gt;
                        &lt;BR /&gt;
proc report data=sashelp.prdsale nofs &lt;BR /&gt;
    missing nocenter;&lt;BR /&gt;
    where actual &amp;gt;= 500;&lt;BR /&gt;
                 &lt;BR /&gt;
column country region product &lt;BR /&gt;
       country=country2 region=region2 &lt;BR /&gt;
       product=product2&lt;BR /&gt;
       actual predict n;&lt;BR /&gt;
                &lt;BR /&gt;
  define country / group noprint;&lt;BR /&gt;
  define region / group noprint;&lt;BR /&gt;
  define product / group noprint;&lt;BR /&gt;
  define country2 / group;&lt;BR /&gt;
  define region2 / group;&lt;BR /&gt;
  define product2 / group;&lt;BR /&gt;
  define actual / sum;&lt;BR /&gt;
  define predict / sum;&lt;BR /&gt;
  define n / noprint;&lt;BR /&gt;
  rbreak before / summarize;&lt;BR /&gt;
  compute before;&lt;BR /&gt;
    country2 = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  compute after;&lt;BR /&gt;
    country2 = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute before _page_;&lt;BR /&gt;
    rows = n + 7;&lt;BR /&gt;
    line 'N=' N ' Rows (N+7) =' Rows;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
ods tagsets.excelxp close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 18 Dec 2008 07:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66312#M7684</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-12-18T07:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66313#M7685</link>
      <description>Yes, a solution to this would require turning off cell merging (but merging cells is never a good idea anyway, in my opinion).&lt;BR /&gt;
&lt;BR /&gt;
The cells with the subtotal formulas have to be above the filters, or the filters won't work right (and neither will the subtotals), so COMPUTE BEFORE and COMPUTE AFTER don't have the desired result.</description>
      <pubDate>Thu, 18 Dec 2008 18:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66313#M7685</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2008-12-18T18:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66314#M7686</link>
      <description>I'm trying something different now - a separate PROC REPORT to create the headers.  That way I can have multiple cells.  Here's some sample code, still a work in progress:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
options nocenter;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.ExcelXP&lt;BR /&gt;
      file='c:\temp\subtotal.xls'&lt;BR /&gt;
         options(&lt;BR /&gt;
            embedded_titles='yes'&lt;BR /&gt;
            row_repeat='7'&lt;BR /&gt;
            frozen_headers='7'&lt;BR /&gt;
            autofilter='no'&lt;BR /&gt;
            sheet_interval='none'&lt;BR /&gt;
            orientation='landscape'&lt;BR /&gt;
            );&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
&lt;BR /&gt;
title 'Excel Subtotal';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   create table groups as &lt;BR /&gt;
      select distinct&lt;BR /&gt;
               country,&lt;BR /&gt;
               region,&lt;BR /&gt;
               product,&lt;BR /&gt;
               sum(actual) as actual,&lt;BR /&gt;
               sum(predict) as predict&lt;BR /&gt;
      from     &lt;BR /&gt;
               sashelp.prdsale&lt;BR /&gt;
      where    &lt;BR /&gt;
               actual &amp;gt; 500&lt;BR /&gt;
      group by &lt;BR /&gt;
               country,&lt;BR /&gt;
               region,&lt;BR /&gt;
               product&lt;BR /&gt;
      ;&lt;BR /&gt;
   create table rows as &lt;BR /&gt;
      select &lt;BR /&gt;
               count(*) as rows &lt;BR /&gt;
      from&lt;BR /&gt;
               groups; &lt;BR /&gt;
   select &lt;BR /&gt;
            rows     &lt;BR /&gt;
   into     &lt;BR /&gt;
            :ROWS&lt;BR /&gt;
   from&lt;BR /&gt;
            rows; &lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data empty_groups;&lt;BR /&gt;
   output;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   set groups;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=empty_groups nofs missing nocenter split='!';&lt;BR /&gt;
   define country / 'Selected!Records';&lt;BR /&gt;
   define region  / '';&lt;BR /&gt;
   define product / '';&lt;BR /&gt;
   define actual  / 'Sum of!Actual';&lt;BR /&gt;
   define predict / 'Sum of!Predict';&lt;BR /&gt;
   compute region;&lt;BR /&gt;
      region = 'of ' || left(put(&amp;amp;ROWS., comma6.0));&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.ExcelXP&lt;BR /&gt;
         options(&lt;BR /&gt;
            embedded_titles='no'&lt;BR /&gt;
            autofilter='all'&lt;BR /&gt;
            );&lt;BR /&gt;
&lt;BR /&gt;
proc report data=sashelp.prdsale nofs missing nocenter;&lt;BR /&gt;
   where actual &amp;gt;= 500;&lt;BR /&gt;
&lt;BR /&gt;
   column country region product &lt;BR /&gt;
          country=country2 region=region2 product=product2&lt;BR /&gt;
          actual predict n;&lt;BR /&gt;
&lt;BR /&gt;
   define country  / group noprint;&lt;BR /&gt;
   define region   / group noprint;&lt;BR /&gt;
   define product  / group noprint;&lt;BR /&gt;
   define country2 / group;&lt;BR /&gt;
   define region2  / group;&lt;BR /&gt;
   define product2 / group;&lt;BR /&gt;
   define actual   / sum;&lt;BR /&gt;
   define predict  / sum;&lt;BR /&gt;
   define n        / noprint;&lt;BR /&gt;
&lt;BR /&gt;
   compute before _page_;&lt;BR /&gt;
      rows = n + 9;&lt;BR /&gt;
      line '="Total of ACTUAL in selected records: " &amp;amp; text(subtotal(9,r5c4:r' rows z5. 'c4), "$ #,##0.00")';&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.excelxp close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
options noxwait noxsync;&lt;BR /&gt;
&lt;BR /&gt;
x 'start c:\temp\subtotal.xls';&lt;BR /&gt;
=====&lt;BR /&gt;
&lt;BR /&gt;
The problem is that the AUTOFILTER is being applied to the first proc report and not the second, but I want just the opposite - I want the first, single-row PROC REPORT to not have any filters, and the second, multiple-data-row PROC REPORT to have filters.&lt;BR /&gt;
&lt;BR /&gt;
How do I do that?&lt;BR /&gt;
&lt;BR /&gt;
After that problem is solved, I will add compute blocks to the first PROC REPORT to place the appropriate formulas into the cells.  But there's no point in doing that if I can't get the filters moved to the right place.</description>
      <pubDate>Tue, 30 Dec 2008 17:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66314#M7686</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2008-12-30T17:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Rows above header in PROC REPORT?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66315#M7687</link>
      <description>Jack:&lt;BR /&gt;
  Here's my idea -- take SAS out of the picture. This is what I mean:&lt;BR /&gt;
&lt;BR /&gt;
1) Make an Excel spreadsheet (without SAS) by typing in dummy tables and numbers and the headers the way you want and autofiltering the way you want and -then- save that spreadsheet as a .XML file (XML 2003 -- NOT XML 2007).&lt;BR /&gt;
&lt;BR /&gt;
2) Next, take the spreadsheet that you're getting from SAS and cut the data WAY down -- so that you have the top info and the 2nd table and the broken filtering.&lt;BR /&gt;
&lt;BR /&gt;
Now, open both XML files in NOTEPAD and see in #1 where Excel wants the autofiltering XML instructions to be placed when SAS is out of the picture and then see what the difference is in #2 where SAS places the autofiltering tags. I'm guessing that there's some quirky tag or way to define autofiltering that Excel does that the current ExcelXP tagset is not putting in the same place as Excel lets you do manually. I have found this in a few cases that Excel will let me do something and save the file as XML but I can't get there with the ExcelXP tagset -- it was never a deal breaker for me, but I did discover that sometimes Excel puts tags in the file in places that ODS is not geared up for.&lt;BR /&gt;
&lt;BR /&gt;
Of course, it would also be good to find whether native Excel will let you have the equivalent of 2 tables in one sheet and put will autofiltering on the 2nd table. If Excel does allow that (which you will find out when you do #1), then you will know how that XML is supposed to look. And then if your comparison of the 2 XML files reveals WHERE the tags for autofiltering are supposed to go and what the differences are,  then you may need to customize the ExcelXP tagset to contain a custom event that writes out the autofiltering XML on the 2nd table only.&lt;BR /&gt;
&lt;BR /&gt;
At least you'll find out whether it's possible before you go down the custom tagset road. That's my idea. (Eric may have a different one!)&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 30 Dec 2008 18:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Rows-above-header-in-PROC-REPORT/m-p/66315#M7687</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-12-30T18:09:17Z</dc:date>
    </item>
  </channel>
</rss>

