BookmarkSubscribeRSS Feed
SASUserMD
Obsidian | Level 7

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.

5 REPLIES 5
ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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

SASUserMD
Obsidian | Level 7

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.

SASUserMD
Obsidian | Level 7

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.

SASUserMD
Obsidian | Level 7

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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3253 views
  • 0 likes
  • 3 in conversation