I'm trying to add bookmarks to an ods pdf output, but I'm struggling to get them to apply to some but not all of the tables.
Here's what I've tried:
ods pdf file="blah blah blah" startpage=no;
title "table set 1";
ods proclabel "table set 1";
ods text="table 1 from set 1";
proc print data=table11 noobs; run;
ods text="table 2 from set 1";
proc print data=table12 noobs; run;
ods text="table 3 from set 1";
proc print data=table13 noobs; run;
ods pdf startpage=now;
title "table set 2";
ods proclabel "table set 2";
ods text="table 1 from set 2";
proc print data=table21 noobs; run;
ods text="table 2 from set 2";
proc print data=table22 noobs; run;
ods pdf close;
When running this, the table of contents for the pdf is:
table set 1
The Print Procedure
The Print Procedure
table set 2
The Print Procedure
I would like the contents to be:
table set 1
table set 2
How do I either remove the "The Print Procedure" labels, or get a single label to cover multiple tables?
Also, when someone clicks on an item in the contents, they are taken to the table, not the text immediately above it. If I could get the links to go to the text, that would be outstanding.
I am currently using SAS Enterprise Guide 8.3.
You could resort to PROC DOCUMENT .
data a;
set sashelp.class(obs=6);
xc=1;
run;
options nodate nonumber;
title;
ods document name=testAW(write);
Proc report data=a nowd ;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
break before xc / contents="" page;
Run;
Proc report data=a nowd;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
break before xc / contents="" page;
Run;
Proc report data=a nowd ;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
break before xc / contents="" page;
Run;
ods document close;
proc document name=testAW;
list/ levels=all; run;
quit;
proc document name=testAW2(write);
make \CLASS#1;
setlabel \Class#1 "table set 1";
copy \work.testAW\Report#1\Report#1\Report#1 to \Class#1;
copy \work.testAW\Report#2\Report#1\Report#1 to \Class#1;
run;
make \CLASS2#1;
setlabel \Class2#1 "table set 2";
copy \work.testAW\Report#3\Report#1\Report#1 to \Class2#1;
copy \work.testAW\Report#2\Report#1\Report#1 to \Class2#1;
run;
list/ levels=all; run;
quit;
title;
proc document name=work.testAW2;
ods pdf file="c:\temp\twolevels.pdf" startpage=no ;
obtitle \CLASS#1\Report#1 'table set 1';
replay \CLASS#1;
run;
ods pdf startpage=now;
obtitle \CLASS2#1\Report#1 'table set 2';
replay \CLASS2#1;
run;
ods pdf close;
quit;
You could resort to PROC DOCUMENT .
data a;
set sashelp.class(obs=6);
xc=1;
run;
options nodate nonumber;
title;
ods document name=testAW(write);
Proc report data=a nowd ;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
break before xc / contents="" page;
Run;
Proc report data=a nowd;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
break before xc / contents="" page;
Run;
Proc report data=a nowd ;
Columns xc name age weight height;
define xc /order noprint;
Define name /display;
break before xc / contents="" page;
Run;
ods document close;
proc document name=testAW;
list/ levels=all; run;
quit;
proc document name=testAW2(write);
make \CLASS#1;
setlabel \Class#1 "table set 1";
copy \work.testAW\Report#1\Report#1\Report#1 to \Class#1;
copy \work.testAW\Report#2\Report#1\Report#1 to \Class#1;
run;
make \CLASS2#1;
setlabel \Class2#1 "table set 2";
copy \work.testAW\Report#3\Report#1\Report#1 to \Class2#1;
copy \work.testAW\Report#2\Report#1\Report#1 to \Class2#1;
run;
list/ levels=all; run;
quit;
title;
proc document name=work.testAW2;
ods pdf file="c:\temp\twolevels.pdf" startpage=no ;
obtitle \CLASS#1\Report#1 'table set 1';
replay \CLASS#1;
run;
ods pdf startpage=now;
obtitle \CLASS2#1\Report#1 'table set 2';
replay \CLASS2#1;
run;
ods pdf close;
quit;
This looks like exactly what I'm looking for! I'll try to figure out how PROC DOCUMENT works then get my contents page nice and fancy!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.