Help using Base SAS procedures

ODS Reporting Questions

Reply
Occasional Contributor
Posts: 10

ODS Reporting Questions

Hi--

I’ve put together a report, which uses a series of Proc tabulate statements.  I’m having trouble figuring out a few basic finishing touches. I have been looking through the documentation and been having some trouble.

  1. I would like to have a cover page with the title of the report and  with the title styled.
  2. I would like I footer with a text and the pagenumber left justified. So obviously I don’t want a page number on the cover page.

Thanks!

SAS Super FREQ
Posts: 8,864

Re: ODS Reporting Questions

Hi:

  This previous forum posting (http://communities.sas.com/message/14679#14679) shows the use of a SAS dataset and ODS ESCAPECHAR to make a "title" page dataset. Then the WORK.TITLE dataset is sent to ODS using PROC REPORT as a first page. By toggling NODATE, NONUMBER options, you can turn off the automatic creation of page numbers and then take control of page numbers in a footnote using the ODS ESCAPECHAR functions {THISPAGE} and {LASTPAGE}. Since you did not say what version of SAS you are using, this example uses the 9.1.3 syntax for ODS ESCAPECHAR. There is a newer syntax for 9.2 and plenty of SAS Global Forum papers and forum postings that show the newer syntax. However, for what you want to do, this syntax should work for 9.1.3 and/or 9.2 and/or 9.3.

  Otherwise, if you do not use this technique for creating a title page, then you will have to go down the ODS LAYOUT road to make your title page-- which is still a pre-production feature of ODS. The attached screenshot shows an example of a title page and a TABULATE output using a modified version of the above program.

cynthia


title_page_examp.jpg
Occasional Contributor
Posts: 10

Re: ODS Reporting Questions

Posted in reply to Cynthia_sas

Hi Cynthia. Thanks for your help. If you don't mind have some questions.

1. When I run this my proc tabulate tables beginning at the bottom of the title page. When I turn  startpage to "no" only one table generates on each page.

2 I'm still having trouble with the page numbers. I can't seem to figure out how to start the numbering on the secound page.

3.if you have anymore adive on footers, that would be really great.

here is my code:

ods listing close;

                   

options leftmargin="1 in" topmargin="1 in" rightmargin="1 in";

              

options nodate number 

center ps=60 ls=150  pageno=1;

title;

ods pdf file='Z:\SAS\test.pdf'

    startpage=no;

ods escapechar='^';

proc report data=work.Title noheader nowd

      style={rules=none frame=void just=r

             cellspacing=0 cellpadding=4pt};

column line;

define line /right

style(column)={font_weight=bold

                font_face=Arial

                foreground=black};

run;

proc tabulate.............................

Thanks again.

SAS Super FREQ
Posts: 8,864

Re: ODS Reporting Questions

Hi,

  Well with PDF, I tend to begin with STARTPAGE=YES and then turn it off as I need it. The other thing I did was "pad" the bottom of the title page with some blank lines in a modification to the posted program. Then I changed STARTPAGE=NO, after the RUN for the PROC REPORT step.

  That seems to have worked for me -- running with SAS 9.3 on Windows 7. See screen shot.

cynthia

options linesize=256;
** linesize set to max in case want to print title;
** page in the LISTING window.;
ods listing;

title;
footnote;
data work.title;
** this data step creates a file called work.title;
            
drop i;
length line $200;
  ** make some empty lines to pad the top and bottom
     of the title page;
  do i = 1 to 8 by 1;
    line = '  ';
    output;
  end;
line = "~S={font_size=18pt}Some Title Page for the Report";
output;
line = '~S={font_size=18pt}'
       ||'Some Other Line ~S={}';
output;
line= 'Report Period from 01/01/2012 to 02/29/2012 ';
output;
line = "~S={background=black cellheight=1pt font_size=1pt cellpadding=0}"
       ||'                       '||"~S={}";

output;
do i = 1 to 5 by 1;
  line = ' '; output;
  end;
line = '~S={font_size=12pt font_face=Helvetica}'
       ||'February 29,'||'~_'||'2012'
       ||'~S={}';
output;
line = '~S={font_size=12pt font_face=Helvetica}'
       ||'Investigator: Some Person'
       ||'~S={}';
output;
line = '~S={font_size=12pt font_face=Helvetica}'
       ||'Analyst: Anne Analyst'
       ||'~S={}';
output;
** pad the bottom;
  do i = 1 to 8 by 1;
    line = '  ';
    output;
  end;
run;

  

** close listing and set options for title page;
** and output;

 
ods listing close;

options leftmargin="1 in" topmargin="1 in"
        rightmargin="1 in" bottommargin="1 in"
        nodate nonumber orientation=portrait;

 

** the proc report step prints work.title;
** created in the data step above;
** followed by a series of PROC TABULATE tables;
** use STARTPAGE=YES to begin;

 
ods pdf file='c:\temp\do_title_page.pdf'
    startpage=yes;
ods escapechar='~';

  
** blank out any existing title/footnote lines;
title;
footnote;

 

proc report data=work.title noheader nowd
      style={rules=none frame=void just=r
             cellspacing=0 cellpadding=4pt};
column line;
define line /
style(column)={just=r font_weight=bold
                font_face=Arial
                foreground=black};
run;

** end PROC REPORT;
** issue TITLE, FOOTNOTE and turn PAGENO=1;
   
title 'Proc TABULATE'; 
footnote j=l h=12pt 'Page ~{thispage} of ~{lastpage}'
         j=c h=14pt 'Some Text'
         j=r h=12pt 'Tabulate Report';
              
options nodate nonumber pageno=1;
** set ODS PDF STARTPAGE=NO;
ods pdf startpage=no; run;
      
** start PROC TAB with multiple TABLE statements;
** will probably make 2/3 pages including title page;
proc tabulate data=sashelp.shoes f=comma12.;
class region product subsidiary;
var sales inventory returns;
table product all,
      sales*(n sum mean)/box='Product Sales';
table product all,
      returns*(n sum mean) / box='Product Returns';
table product all,
      inventory*(n sum mean) / box='Product Inventory';
table region all,
      sales*(n sum mean) / box='Region Sales';
  
run;
ods _all_ close;
title;


title_page_examp2.jpg
Super User
Posts: 10,023

Re: ODS Reporting Questions

Just as Cynthia showed it for you.

You can use options pageno=1 to re-set the page number before any proc tabulate

Ksharp

Occasional Contributor
Posts: 10

Re: ODS Reporting Questions

This is great. Thanks I'm sorry I have one last question. Some the sections in my report a not separating out properely and unding up under different titles.   How do a let sas know to when to start I new page ?

I'll have

TITLE Section A

Table 1

Table 2

Table 3

new page

TITLE A

table 4

table 6 but table 6 should be under  Section B

table 7 but table 7  should be under  Section B

next page

TITLE Section B

table 8

Here I question want Q1 and Q2 inn the servcies section

proc tabulate data=Want (where=(question in('Q1','Q2')));

  title 'SERVICES ';

  class  question name responce;

  classlev question program_name responce1;

  tables Question=' ',

        name =' '*(n pagepctn*f=pctfmt.) all*(n pagepctn*f=pctfmt.),

         responce1=' ' all 

         / row=float

           box={label='Count^{newline 1}Overall^_%}';

  keylabel all='Total'

           n=' '

           pagepctn=' ';

  keyword all n pagepctn;

run;

***here I need to let sas  know I want to start a new page for these tables  but continue the page numbering*/

proc tabulate data=Want (where=(question in('Q5','Q7,Q10')));

  title 'SERVICES ';

  class  question name responce;

  classlev question name  Responce1;

  tables Question=' ',

        name =' '*(n pagepctn*f=pctfmt.) all*(n pagepctn*f=pctfmt.),

         responc1=' ' all 

         / row=float

           box={label='Count^{newline 1}Overall^_%}';

  keylabel all='Total'

           n=' '

           pagepctn=' ';

  keyword all n pagepctn;

run;

SAS Super FREQ
Posts: 8,864

ODS Reporting Questions

Hi:

  You may need to use the STARTPAGE=NOW command to issue an immediate "page break". Or, you may need to "pad" a TABULATE with a few blank lines using ODS TEXT= statements.

  Just as I issued

** set ODS PDF STARTPAGE=NO;

ods pdf startpage=no; run;

you may want to try:

** set ODS PDF STARTPAGE=NOW;

ods pdf startpage=now; run;

before your sections. At this point, the way that pages are breaking are dependent on your data and how big your tables are, etc, etc. You might want to open a track with Tech Support because they can look at your exact data and if you are not running SAS 9.3, they can replicate your version of SAS to help you come to the right solution for your data and your version of SAS.

cynthia

Ask a Question
Discussion stats
  • 6 replies
  • 362 views
  • 0 likes
  • 3 in conversation