The SAS Output Delivery System and reporting techniques

Ods tagsets.rtf, page break and titles

Accepted Solution Solved
Reply
Contributor
Posts: 73
Accepted Solution

Ods tagsets.rtf, page break and titles

Hi !

I'm lost with the ODS tagsets.rtf and I would like to share my problem with you.

Here the code. I would like three pages and at the top of each page I would like a title ; on each page I would like two tables. First : Is it possible ? Why this code refuse to produce what I want ?

I add text= in order to simulate a title for each table. if you have a better idea...

ods tagsets.rtf file="C:\test.rtf" options (contents="yes" toc_data="on" sect="NO") startpage=no;

title "page 1";

Ods tagsets.rtf text="Premier tableau";

proc print data=sashelp.class (obs=1);

run;

ODs tagsets.rtf text="second tableau";

proc print data=sashelp.class (obs=2);

run;

ods tagsets.rtf startpage=now;

title "page 2";

Ods tagsets.rtf text="Troisième tableau";

proc print data=sashelp.class (obs=1);

run;

ODs tagsets.rtf text="Quatrième tableau";

proc print data=sashelp.class (obs=2);

run;

ods tagsets.rtf startpage=now;

title "page 3";

Ods tagsets.rtf text="Cinquième tableau";

proc print data=sashelp.class (obs=1);

run;

ODs tagsets.rtf text="Sixième tableau";

proc print data=sashelp.class (obs=2);

run;

ods _all_ close;

Thank you for your help.


Accepted Solutions
Solution
‎09-25-2012 06:18 PM
SAS Super FREQ
Posts: 8,742

Re: Ods tagsets.rtf, page break and titles

HI:

  Aside from any page break issues, if you look at the output  files from the attached program, you will see the TOC level customization that you can do with ODS PROCLABEL and CONTENTS= with PRINT, REPORT, TABULATE and FREQ. If you use ODS PROCLABEL, you are explicitly telling ODS what is the text string for labelling the top level node that should be placed in the TOC. Without any ODS PROCLABEL information, the procedure determines the text that goes into the TOC. And even with ODS NOPTITLE in effect, the titles used for PRINT and REPORT in the first output's TOC are: The PRINT Procedure and The REPORT Procedure.

This means that, in the first (smaller) example below, the TOC reflects the names that the procedures send (and not the SAS TITLES) -- so there never been an automatic way to put the SAS title into the TOC. If you made your ODS PROCLABEL value the SAME as your SAS title, then it might appear as though the title is being used. In my second example, I made the ODS PROCLABEL string and the TITLE different so you could see exactly which string was used in the TOC.

  That takes care of the "top level" for each step in the TOC. The secondary levels you may or may not have control over. PRINT, REPORT, TABULATE and FREQ all support the use of CONTENTS= option to change at least one of the secondary (or tertiary) level strings.

  To rearrange or restructure your TOC completely, usually requires using ODS DOCUMENT and PROC DOCUMENT.  So, for example to "flatten" the structure of the TOC or eliminate levels, you can play around with CONTENTS=' ' (quote space quote) to suppress levels, but sometimes, that doesn't completely suppress the level, just blanks out the string for the level. ODS DOCUMENT is the best way to rearrange and restructure your output so the TOC is the way you want.

  Code below does not venture into ODS DOCUMENT territory. There have been many previous examples of that posted in the forum and at past user group site. But the code below does illustrate the use of ODS PROCLABEL in conjunction with CONTENTS=. To keep things simple and unmuddied, I did not get into STARTPAGE issues.

cynthia

** default -- show only 2 procedures;
** by default, titles are not inserted into the TOC;
ods tagsets.rtf file='c:\temp\show_toc_defaults.rtf'
    options(contents='yes' toc_data='yes' sect='no');
ods noptitle;
  
title '1) Title';
proc print data=sashelp.shoes(obs=5);
  var product region sales inventory returns;
run;
  
title '2) Title';
proc report data=sashelp.cars(obs=5) nowd;
  column make model type drivetrain msrp;
run;
       
ods _all_ close;
 

**shows use of ods proclabel and contents=;

ods tagsets.rtf file='c:\temp\showproclabel.rtf'
    options(contents='yes' toc_data='yes' sect='no');
ods noptitle;
  
ods proclabel 'One';
title '1) Title';
proc print data=sashelp.shoes(obs=5)
  contents='Proc Print Top';
  var product region sales inventory returns;
run;
  
ods proclabel 'Two';
title '2) Title';
proc report data=sashelp.cars(obs=5) nowd
     contents='Proc Report Top';
  column make model type drivetrain msrp;
run;
    
ods proclabel 'Three';
title '3) Title';
proc tabulate data=sashelp.class
     contents='Proc Tabulate Top';
  class age sex;
  var height;
  table age all,
        sex*height*mean /
        contents='Table Stmt';
run;
    
ods proclabel 'Four';
title '4) Title';
proc freq data=sashelp.prdsale;
  tables country*division / nocum nopercent
         contents='Proc Freq Top';
run;
   
ods proclabel 'Five';
title '5) Title';
** proc means does not support CONTENTS=;
proc means data=sashelp.heart n mean min max;
  var ageatdeath cholesterol;
  class chol_status;
run;
ods _all_ close;

View solution in original post


All Replies
Super User
Posts: 10,483

Re: Ods tagsets.rtf, page break and titles

When I run your example code I get one page for the table of contents followed by 3 pages each with 2 tables.

Your title statemens for pages 2 and 3 should go before the Startpage=now. Otherwise I in Windows 7 running Sas 9.2.3 this appears to be generating what you specifiy.

You may want the option BODYTITLE or BODYTITLE_AUX if you want to use TITLE statements instead of the TEXT=. Otherwise titles go into the page header and footer (in Word) and you don't get your table specific titles quite where you want them.

Contributor
Posts: 73

Re: Ods tagsets.rtf, page break and titles

Really ?

I have w7 x64 yet.

OK Thank you anyway for the tips about the title this is another tricky point for me. But one question again : these titles will be on the contents table on the first page ? I would like that and only the titles. Is it possible ? I saw that I need to use PROCLABEL or something like that but I don't understand.


Solution
‎09-25-2012 06:18 PM
SAS Super FREQ
Posts: 8,742

Re: Ods tagsets.rtf, page break and titles

HI:

  Aside from any page break issues, if you look at the output  files from the attached program, you will see the TOC level customization that you can do with ODS PROCLABEL and CONTENTS= with PRINT, REPORT, TABULATE and FREQ. If you use ODS PROCLABEL, you are explicitly telling ODS what is the text string for labelling the top level node that should be placed in the TOC. Without any ODS PROCLABEL information, the procedure determines the text that goes into the TOC. And even with ODS NOPTITLE in effect, the titles used for PRINT and REPORT in the first output's TOC are: The PRINT Procedure and The REPORT Procedure.

This means that, in the first (smaller) example below, the TOC reflects the names that the procedures send (and not the SAS TITLES) -- so there never been an automatic way to put the SAS title into the TOC. If you made your ODS PROCLABEL value the SAME as your SAS title, then it might appear as though the title is being used. In my second example, I made the ODS PROCLABEL string and the TITLE different so you could see exactly which string was used in the TOC.

  That takes care of the "top level" for each step in the TOC. The secondary levels you may or may not have control over. PRINT, REPORT, TABULATE and FREQ all support the use of CONTENTS= option to change at least one of the secondary (or tertiary) level strings.

  To rearrange or restructure your TOC completely, usually requires using ODS DOCUMENT and PROC DOCUMENT.  So, for example to "flatten" the structure of the TOC or eliminate levels, you can play around with CONTENTS=' ' (quote space quote) to suppress levels, but sometimes, that doesn't completely suppress the level, just blanks out the string for the level. ODS DOCUMENT is the best way to rearrange and restructure your output so the TOC is the way you want.

  Code below does not venture into ODS DOCUMENT territory. There have been many previous examples of that posted in the forum and at past user group site. But the code below does illustrate the use of ODS PROCLABEL in conjunction with CONTENTS=. To keep things simple and unmuddied, I did not get into STARTPAGE issues.

cynthia

** default -- show only 2 procedures;
** by default, titles are not inserted into the TOC;
ods tagsets.rtf file='c:\temp\show_toc_defaults.rtf'
    options(contents='yes' toc_data='yes' sect='no');
ods noptitle;
  
title '1) Title';
proc print data=sashelp.shoes(obs=5);
  var product region sales inventory returns;
run;
  
title '2) Title';
proc report data=sashelp.cars(obs=5) nowd;
  column make model type drivetrain msrp;
run;
       
ods _all_ close;
 

**shows use of ods proclabel and contents=;

ods tagsets.rtf file='c:\temp\showproclabel.rtf'
    options(contents='yes' toc_data='yes' sect='no');
ods noptitle;
  
ods proclabel 'One';
title '1) Title';
proc print data=sashelp.shoes(obs=5)
  contents='Proc Print Top';
  var product region sales inventory returns;
run;
  
ods proclabel 'Two';
title '2) Title';
proc report data=sashelp.cars(obs=5) nowd
     contents='Proc Report Top';
  column make model type drivetrain msrp;
run;
    
ods proclabel 'Three';
title '3) Title';
proc tabulate data=sashelp.class
     contents='Proc Tabulate Top';
  class age sex;
  var height;
  table age all,
        sex*height*mean /
        contents='Table Stmt';
run;
    
ods proclabel 'Four';
title '4) Title';
proc freq data=sashelp.prdsale;
  tables country*division / nocum nopercent
         contents='Proc Freq Top';
run;
   
ods proclabel 'Five';
title '5) Title';
** proc means does not support CONTENTS=;
proc means data=sashelp.heart n mean min max;
  var ageatdeath cholesterol;
  class chol_status;
run;
ods _all_ close;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1365 views
  • 3 likes
  • 3 in conversation