The SAS Output Delivery System and reporting techniques

Table of Contents in SAS

Reply
Occasional Contributor
Posts: 7

Table of Contents in SAS

Hi,

I am trying to make a report in SAS. In the report I am making graphs using Proc gplot then exporting them to a pdf using ods pdf. 

I also want Table of Contents in the front of the page with title & page number of the graphs.

When I use proclabel I get the bookmarks but not a proper Table of Contents like we get from word or any such  software.

Does anyone know how can I get a proper TOC in the beginning of my report before the graphs are plotted?

 

Thanks

monika

SAS Super FREQ
Posts: 8,743

Re: Table of Contents in SAS

Hi,
Generally, with ODS PDF, you get the separate TOC page by using the contents=yes option:

ods pdf file='xxx.pdf' contents=yes;
** first proc;
** second proc;
** third proc;
ods pdf close;

As long as one of your procedures is a SAS/GRAPH procedure "inside" the ODS "sandwich", then you should be getting a separate TOC page in the PDF document.

cynthia
Super User
Super User
Posts: 7,401

Re: Table of Contents in SAS

Might want to clarify what is meant by "proper TOC" from Word as I have had this a lot over the years, things like page numbering, links to pages and such like is just very difficult in SAS.   

Occasional Contributor
Posts: 7

Re: Table of Contents in SAS

Thanks for writing RW9. Yes, I am looking for page numbering, customized titles, and may be customized fonts and font size as well.
Super User
Super User
Posts: 7,401

Re: Table of Contents in SAS

Well, Cynthia is the SAS ODS expert, so I will just talk from my experience.  I would personally do it this way.  Output all files to RTF - in my industry it is standard to provide individual files anyway.  Once you have these files combine them in word and add the TOC there, its pretty straightforward and even manually doesn't take more than a few minutes.  Thn that whole file can be printed to PDF.  

Creating a PDF directly from SAS which has links, relevant page numbers and such like is a real pain.  I have tried it several times with not great results.  Below is an example of where I had got to on this, as you can see I get links and can change fonts and what not, but you will need to calculate page numbers and things before and add them in.  Total faff, thats why I recommend going through Word so you can use ^{thispage} of ^{lastpage} and let Word do all that for you.

ods document name=work.full_print (write);
ods noproctitle;
data work.cars;
	set sashelp.cars;
	flag=1;
run;
data work.class;
	set sashelp.class;
	flag=1;
run;
data work.x;
	attrib tct format=$200. ;
	flag=1;
	tct="^S={just=left vjust=middle cellheight=20pt font_size=10pt cellwidth=15cm linkcolor=white url='#rep1'} My link to cars section ^{thispage}"; output;
	tct="^S={just=left vjust=middle cellheight=20pt font_size=10pt cellwidth=15cm linkcolor=white url='#rep2'} My link to class section ^{thispage}"; output;
run;

title;
footnote;

proc report data=work.x nowd contents="" split='~' ls=256 ps=207 list missing
						style(column) = {font_size=6pt background=white just=l borderrightcolor=white borderleftcolor=white
                           				 bordertopcolor=white borderbottomcolor=white linkcolor=white}
						style(header) = {font_size=6pt background=white just=c borderrightcolor=white borderleftcolor=white
                           				 bordertopcolor=white borderbottomcolor=white linkcolor=white};
	column flag tct;
	define tct / "Table of Contents" style={font_size=10pt just=c background=white borderrightcolor=white borderleftcolor=white
                           				      bordertopcolor=white borderbottomcolor=white linkcolor=white};
	define flag / noprint order;
	break before flag / page contents='';
run;

title j=c "Cars";
proc report data=work.cars nowd contents="";
	define flag / noprint order;
	break before flag / page contents='';
run;
title j=c "Class";
proc report data=work.class nowd contents="";
	define flag / noprint order;
	break before flag / page contents='';
run;
ods document close;

ods pdf file="S:\Temp\Rob\Content.pdf";
proc document name=work.full_print;
	list/levels=all; run;
quit;
ods pdf close;

ods pdf file="S:\Temp\Rob\Content2.pdf" /*contents=yes*/;
proc document name=work.full_print (update);
	ods escapechar="^";
	setlabel Report#1 "Table of Contents";
	setlabel Report#2 "Cars"; run;
	setlabel Report#3 "Class"; run;
	ods pdf anchor="toc"; 
	replay Report#1; run; 
	ods pdf anchor="rep1";
	replay Report#2; run;
	ods pdf anchor="rep2";
	replay Report#3; run;
quit;
ods pdf close;


	
Occasional Contributor
Posts: 7

Re: Table of Contents in SAS

Thanks for replying Cynthia. I do get TOC by using contents=yes option. Actually, what I meant was having a TOC with page number and customized titles, may be customized fonts and font size as well.
Ask a Question
Discussion stats
  • 5 replies
  • 690 views
  • 0 likes
  • 3 in conversation