The SAS Output Delivery System and reporting techniques

Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

Reply
Occasional Contributor
Posts: 7

Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

Hello,

 

I have some trubble by creating a document (only table of contens on the front page) by using SAS 9.4. I got the following example:

 

ODS ESCAPECHAR ='~';
ODS noproctitle; 
OPTIONS orientation=landscape PAPERSIZE="ISO A4" NOdate NOnumber NOQUOTELENMAX center pageno=1;
ODS RTF nobodytitle notoc_data startpage=no;
title1 j=l 'Project' j=r 'page ~{PAGEOF}'; 
title2 j=l 'Table of Contents';

	*to creat TOC;
	ods rtf text='~S={outputwidth=100% just=l}{\field{\*\fldinst {\\TOC \\f \\h} } \par }'; 

ods rtf startpage=now;

title2 j=l 'Analysis'; 
title3 j=l '1. Origin'; 
*Information to print in TOC;
ods rtf text="~S={outputwidth=100% just=l} {\tc\b\f3\fs0\cf8 Analysis}"; 
ods rtf text="~S={outputwidth=100% just=l} {\tc\b\f3\fs0\cf8 1. Origin}"; 

	PROC TABULATE data=sashelp.cars;
		class Origin;  
		table Origin,(N pctn='%'*F=4.1); 
	RUN;  

ods rtf startpage=now;

title3 j=l '2. DriveTrain'; 
ods rtf text="~S={outputwidth=100% just=l} {\tc\b\f3\fs0\cf8 2. DriveTrain}"; 

	PROC TABULATE data=sashelp.cars;
		class DriveTrain;  
		table DriveTrain,(N pctn='%'*F=4.1); 
	RUN;  

ods rtf close;

Using SAS 9.2 this code would create 3 pages:

p1 - Table of Contents
p2 - 1. Origin
p2 - 2. DriveTrain

 

But if you use SAS 9.4 there were just 2 pages. How can I get an extra page for the table of contents with SAS 9.4?

At the moment I handle the problem by creating a simple print-note:

 

	DATA TEXT;
		text="please delete";
	RUN;

	PROC PRINT DATA=TEXT;
		var text;
	RUN;

After creating the document you have to delete the note. This is an easy way for one document but not for a automatic report.

 

Hope someone can help me.

 

Thx.

Grand Advisor
Posts: 9,680

Re: Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

Did you go to the document in Word or a similar program and attempt to use the program features to build the TOC? That information is in a field that you have to activate.

Use the a "reveal codes" feature to see where that may be on the page.

 

Or possibly the behavior in the word processor has changed. Wouldn't be the first time that's happened.

SAS Super FREQ
Posts: 8,641

Re: Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

Hi:

Not really sure why you are using your own RTF control strings. Typically, if you use TOC_DATA and CONTENTS=YES, with ODS RTF, the first page is a table of contents and the subsequent pages have the procedure output. Using TOC_DATA causes ODS to insert the appropriate text strings into the document.

 

Although since you are also using STARTPAGE with the RTF control strings, I'm not entirely sure that this will work as you expect. I'd suggest opening a track with Tech Support.
 
cynthia

Occasional Contributor
Posts: 7

Re: Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

Thanks. Yes you can also use TOC_DATA but I want all title-information's in the TOC. We are generating reports with serval titels. E.g.:

1. Titel1

1.1 Titel1.1

1.1.1 Titel1.1.1

Table

1.1.2 Titel1.1.2

Table

1.2 Titel1.2

1.1.1 Titel1.2.1

Table

...

And I want all these information's in the TOC. That's why I'm using this code: www2.sas.com/proceedings/forum2008/238-2008.pdf

 

SAS Support couldn't help me so far. Just send me serval links.

Occasional Contributor
Posts: 7

Re: Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

I know, I have done this. TOC and the first table are now on the same page. But I want the first page with TOC only and afterwards the tables.

Occasional Contributor
Posts: 7

Re: Ods rtf: How to get the "table of contents" on the front page by using SAS 9.4?

I tried a different output:

 

 

ODS ESCAPECHAR ='~';
ods rtf startpage=no notoc_data;
title1 j=l 'Project' j=r 'page ~{PAGEOF}'; 
title2 j=l 'Text on first page';

	ods rtf startpage=now;
	ods rtf text="Text on first page"; 

ods rtf startpage=now;

title2 j=l 'Analysis'; 
title3 j=l '1. Origin'; 

	PROC TABULATE data=sashelp.cars;
		class Origin;  
		table Origin,(N pctn='%'*F=4.1); 
	RUN;  

ods rtf startpage=now;

title3 j=l '2. DriveTrain'; 
ods rtf text="~S={outputwidth=100% just=l} {\tc\b\f3\fs0\cf8 2. DriveTrain}"; 

	ods rtf text="TEST"; 

ods rtf close;

Problem is: You can't get a new page by using "ods rtf text" at the first page. But why? It's working fine at any other position in the document.

 

Post a Question
Discussion Stats
  • 5 replies
  • 323 views
  • 0 likes
  • 3 in conversation