BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_Manhattan
Obsidian | Level 7

Hello,

While attempting to create an automatic Table of Contents (TOC) for a PDF file, I encountered a few difficulties. The idea behind my TOC was to create an interactive TOC that includes the heading names and allows the user to navigate to the respective page with a mouse click. I was hoping that I may be able to customize the first proc report step of each page and change the name of this proc report step via the “ods proclabel = Header(1, 2, 3)” statement.

So far:
By running my code and using the "ods pdf" statements and the "contents = yes" option, an automatic TOC is generated, listing three levels with page numbers per Proc step. Using "ods proclabel = "header"", it is possible to name the first level as intended (Name of "Header"). By using the "contents = """ option for the respective Proc steps, it is possible to remove one of the three levels. However, I am not able to delete the unnecessary information or proc report steps left (e. g. “Proc report” or “Tabelle 1”). All yellow marked Information is declared as “unnecessary Information” (I just want to keep the renamed first proc report steps = "Header"):

Jakobsen96_0-1686142714287.png

 

Issues:

  • All Proc steps are listed per page, and some of them should be excluded from the TOC.
  • "ods proclabel = """ does not delete the entries of the unnecessary information/proc report steps.
  • I'm not aware of a way to delete the third entry, "Tabelle 1".

Questions:

  • Is there a way to completely ignore specific Proc steps for TOC generation? (unnecessary information)
  • Can the third entry, "Tabelle 1" be removed? (unnecessary information)

And if the customization of the TOC does not work as I intended:

  • Is there a way to automatically include the headings created with "ods text" statements in the Table of Contents, along with their respective page numbers as an alternative way of generating the TOC and just ignore ALL the proc report steps?
/* generate TOC */
libname verein 'yourpath';

/* Erstellung Beispieldaten in Libref "verein" */
data verein.beispieldaten;
	Input Name $ Alter Geschlecht $ Monatsbeitrag Mitgliedsjahre;
	Datalines;
	Meier 56 M 10.10 26
	Schmidt 50 W 65.02 7
	Lehmann 45 W 71.20 6
	Mueller 22 W 56 2
	Johnson 19 M 26 1
	Smith 23 M 80 2
	Jones 80 W 60 11
	;
run;

/*
-> ods proclabel = "Header"  (first level TOC entry)
-> contents = ""  (second-level TOC entry)
*/
/*** Produce report ***/
/** Define options **/
options nonumber orientation=portrait papersize=A4 nodate topmargin=.001in 
	bottommargin=.001in leftmargin=.001in rightmargin=.001in;
ods noproctitle;
ods escapechar="^";
ods noptitle;
options nonumber;

/*---------------------------------------------------------------------------------------------------------------------ods pdf start*/
ods pdf file="yourpath\TOC.pdf" startpage=no 
	contents=yes;
title;

/*------------------------------------------------------------------------------------------------------------------PAGE 1 */
ods pdf startpage=now;
ods layout start width=19cm height=28cm;
ods region y=3cm;
ods text="^{style[font_face='calibri' fontsize=12pt just=center fontweight=bold] Header_1}";
ods text=" ";
ods proclabel="Header_1";

proc report data=verein.beispieldaten contents="";
	column Alter Mitgliedsjahre Monatsbeitrag;
	define Alter/"Alter" display style(header)={just=c} 
		style(column)={just=center};
	define Mitgliedsjahre/ style(header)={just=c} style(column)={just=center};
	define Monatsbeitrag/ style(header)={just=c} style(column)={just=center};
run;

ods region y=7cm x=1.5cm;
ods text="Beispieltext 3";
ods region y=8cm x=3.5cm width=13cm height=8cm;
ods region y=18cm x=1cm;
ods proclabel="";

proc report data=verein.beispieldaten contents="";
	column Alter Monatsbeitrag;
	define Alter/"Alter" style(header)={just=l} style(column)={just=left};
	define Monatsbeitrag/"Monatsbeitrag" style(header)={just=l} 
		style(column)={just=left};
run;

ods region y=27cm x=17cm;
ods text = "^{style[font_face='calibri' fontsize=9pt just=left fontweight=light] ^{thispage}}"; 
ods layout end;

/*---------------------------------------------------------------------------------------------------------------------PAGE 2*/
ods pdf startpage=now;
ods layout start width=19cm height=28cm;
ods region y=2cm x=1.5cm;
ods text="^{style[font_face='calibri' fontsize=12pt just=center fontweight=bold] Header_2}";
ods region y=3cm x=1cm;
ods proclabel="Header_2";

proc report data=verein.beispieldaten contents="";
	column Name Geschlecht Alter;
	define Name/"Name" style(header)={just=l} style(column)={just=left};
	define Geschlecht/"Geschlecht" style(header)={just=l} 
		style(column)={just=center};
	define Alter/"Alter" style(header)={just=l} style(column)={just=center};
run;

ods proclabel="";

proc report data=verein.beispieldaten contents="";
	column Alter Mitgliedsjahre Monatsbeitrag;
	define Alter/"Alter" display style(header)={just=c} 
		style(column)={just=center};
	define Mitgliedsjahre/ style(header)={just=c} style(column)={just=center};
	define Monatsbeitrag/ style(header)={just=c} style(column)={just=center};
run;

ods region y=27cm x=17cm;
ods text = "^{style[font_face='calibri' fontsize=9pt just=left fontweight=light] ^{thispage}}"; 
ods layout end;
ods layout end;

/*---------------------------------------------------------------------------------------------------------------------PAGE 3*/
ods pdf startpage=now;
ods layout start width=19cm height=28cm;
ods region y=2cm x=1.5cm;
ods text="^{style[font_face='calibri' fontsize=12pt just=center fontweight=bold] Header_3}";
ods region y=3cm x=1cm;
ods proclabel="Header_3";

proc report data=verein.beispieldaten contents="";
	title "Titel";
	column Name Geschlecht Alter;
	define Name/"Name" style(header)={just=l} style(column)={just=left};
	define Geschlecht/"Geschlecht" style(header)={just=l} 
		style(column)={just=center};
	define Alter/"Alter" style(header)={just=l} style(column)={just=center};
run;

ods proclabel="";
proc report data=verein.beispieldaten contents="";
	title "Titel";
	column Alter Mitgliedsjahre Monatsbeitrag;
	define Alter/"Alter" display style(header)={just=c} 
		style(column)={just=center};
	define Mitgliedsjahre/ style(header)={just=c} style(column)={just=center};
	define Monatsbeitrag/ style(header)={just=c} style(column)={just=center};
run;

ods region y=27cm x=17cm;
ods text = "^{style[font_face='calibri' fontsize=9pt just=left fontweight=light] ^{thispage}}"; 
ods layout end;
ods layout end;
ods pdf close;

I would greatly appreciate any suggestions, hints, or alternative solutions. Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
Kathryn_SAS
SAS Employee

Here is an example based on the following SAS Note that eliminates the third node:

SAS Note 31278 

data class;
set sashelp.class;
count=1;
run;

ods listing close;
ods pdf file='test.pdf' contents=yes;

ods proclabel='Header 1';
proc report data=class contents='';
column count name age height weight;
define count / order noprint;
break before count / contents='' page;
run;

ods pdf close;
ods listing;

View solution in original post

2 REPLIES 2
Kathryn_SAS
SAS Employee

Here is an example based on the following SAS Note that eliminates the third node:

SAS Note 31278 

data class;
set sashelp.class;
count=1;
run;

ods listing close;
ods pdf file='test.pdf' contents=yes;

ods proclabel='Header 1';
proc report data=class contents='';
column count name age height weight;
define count / order noprint;
break before count / contents='' page;
run;

ods pdf close;
ods listing;
_Manhattan
Obsidian | Level 7

That worked just as intended, thank you so much!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 597 views
  • 0 likes
  • 2 in conversation