currently I'm failing at generating a nice pdf with decent bookmarks and table of contents.
Ideally I want to have a pdf document that looks like this:
Page 1 (title page, portrait orientation)
Page 2 (table of contents, portrait orientation)
Page 3 and further (all tables in subcategories, landscape orientation)
My basic approach is this:
options orientation=portrait nocenter nodate nonumber;
ods pdf file="C:\xyz.pdf" style=sasweb;
ods escapechar='^';
/* Title page */
title;
ods pdf text="^S={just=c} ^20n Document XYZ";
/* ---------- */
/* Table of contents */
ods pdf startpage=now;
title "Contents";
ods pdf text="Classes A & B";
ods pdf text="^S={URL='#Tab1'} Table 1: Class A";
ods pdf text="^S={URL='#Tab2'} Table 2: Class B";
ods pdf text="Classes C & D";
ods pdf text="^S={URL='#Tab3'} Table 3: Class C";
ods pdf text="^S={URL='#Tab4'} Table 4: Class D";
/* ----------------- */
ods pdf startpage=now; /* Start new page ... */
ods pdf startpage=no; /* ... and define no pagination */
title;
options orientation=landscape;
/* Table list */
%macro make_table(in_data=,title=,link=);
ods pdf anchor="&link";
ods proclabel="&title";
ods pdf text="^2n &title";
proc print data=&in_data contents='' noobs;
run;
%mend;
ods pdf text="Classes A & B";
/* Table 1 */
%make_table(in_data=sashelp.class,title=Table 1: Class A,link=Tab1);
/* Table 2 */
%make_table(in_data=sashelp.class,title=Table 2: Class B,link=Tab2);
ods pdf startpage=now;
ods pdf text="Classes C & D";
/* Table 3 */
%make_table(in_data=sashelp.class,title=Table 3: Class C,link=Tab3);
/* Table 4 */
%make_table(in_data=sashelp.class,title=Table 4: Class D,link=Tab4);
/* ---------- */
ods pdf close;
With all this set up I encounter several problems:
It's most probably because of my inexperience with the output delivery system, but I'm struggling for hours now with these seemingly simple problems. Hopefully someone can help me there.
After a lot of trial and error I finally found a way that works for me. I will not post the whole solution as it is relatively long, but in summary I did the following:
Using ods document and proc print all wanted datasets into it.
Created a new ods document and move all output from the previous document into here with a directory structure that pleases me - this enables my previously wanted bookmark structure. I deleted all paginations with obpage and added the table titles via obbnote as well as the correct bookmark naming via setlabel. For some reason I had also to insert two to three carriage returns before each table title. This way my links are not as strange as before.
Instead of this:
ods pdf text="^S={URL='#Tab1'} ...
ods pdf text="^S={URL='#Tab2'} ...
I used this:
ods pdf text="^S={URL='#IDX'} ...
ods pdf text="^S={URL='#IDX1'} ...
This way I didn't have to use the ods pdf anchor - statement which seemed flawed to me (incorrect linking in the table of contents).
Nonetheless I'm still not able to link the subcategories directly to the titles but only to the following table. However, I'm fine with it, so I won't try further.
If anyone is interested in the result, here it comes: link