Hi,
Is there a way to control the collapse of bookmarks in a 3-level bookmarked pdf that is generated via ods pdf?
When generating a pdf I use pdftoc=1 to only show the first level bookmark when opening the pdf, but when I open the top-level bookmark it expands the second and third level bookmarks simultaneously. Is it possible, when opening the top-level bookmark, only all second level bookmarks are showing and keep all third level bookmarks closed? I am looking for a solution directly involving the ods pdf destination or any other options within SAS and NOT for a solution that requires any "external" pdf software.
Thus, when opening APPENDIX D,
instead of getting:
I would like to get this:
It is not easy to control PDF bookmarker in SAS .
How did you create PDF file ?
proc report data=define_xml nowd split="*" contents="" style(report)={outputwidth=100% rules=all} style(header)={font_weight=bold} ; columns memname name label type length _id_; define memname/display noprint; define _id_/order noprint; compute dictionary; rtag = "#"||strip(name); call define(_col_,"url",rtag); call define(_col_,"style","style={foreground=blue}"); n+1; if mod(n,2)=1 then call define(_row_,"style","style={background=verylightgrey}"); endcomp; break before _id_/page contents=""; run;
To control bookmarks I am using ods document.
First I have individual SAS program that can contain several proc report. My general set-up is similar to your code:
ods document name=items.section1(write);
title1 justify = left "Table 14.0.0.0";
ods proclabel = "Table 14.0.0.0";
proc report data = T14000 headline headskip nocenter nowindows missing contents="" split='~' style(header)=[just=right]
style(column)=[just=right] style(report)=[cellpadding=0.8];
columns pageno_ pageno sort1 grp1 trt1;
define pageno_ / order order=internal noprint;
define pageno / order order=internal noprint;
define sort1 / order order=internal noprint;
define grp1 / style(column)=[cellwidth=1.9in just=left] "Protocol Deviation Term" style(header)=[just=left];
define trt1 / style(column)=[cellwidth=1.3in];
break before pageno_ / page contents="" ;
run;
title1 justify = left "Table 14.0.0.1";
ods proclabel = "Table 14.0.0.1";
proc report data = T14001 headline headskip nocenter nowindows missing contents="" split='~' style(header)=[just=right]
style(column)=[just=right] style(report)=[cellpadding=0.8];
columns pageno_ pageno sort1 grp1 trt1;
define pageno_ / order order=internal noprint;
define pageno / order order=internal noprint;
define sort1 / order order=internal noprint;
define grp1 / style(column)=[cellwidth=1.9in just=left] "Protocol Deviation Term" style(header)=[just=left];
define trt1 / style(column)=[cellwidth=1.3in];
break before pageno_ / page contents="" ;
run;
ods document close;
Then I do a proc document (update) to add a new level 1 bookmark, lets call it "Section 1" and place all proc reports (T14.0.0.0 and T14.0.0.1) underneath.
proc document name=items.section1(update);
make section;
dir \ section#1;
setlabel \ section#1 "Section 1";
%macro loop;
%local i table;
%do i=1 %to %sysfunc(countw(&tables.));
%let table = %scan(&tables., &i.);
move \&table.#1 to ^;
%end;
%mend loop;
%loop;
run;
quit;
I create an in-between pdf for Section 1 to evaluate and validate results per section by re-running item section 1 within an ods pdf.
To create a final master pdf containing all sections, I first create a master item, in which all section items a replayed, followed by a proc document (update) to add the title "APPENDIX D"
ods document name=items.masteritem(write);
%macro loop;
%local i section;
%do i=1 %to %sysfunc(countw(§ions.));
%let section = %scan(§ions., &i.);
proc document name=items.§ion.(read);
replay \§ion.;
run;
quit;
%end;
%mend loop;
%loop;
ods document close;
proc document name=items.masteritem(update);
make master;
dir \ master#1;
setlabel \ master#1 "APPENDIX D";
%macro loop;
%local i section;
%do i=1 %to %sysfunc(countw(§ions.));
%let section = %scan(§ions., &i.);
move \§ion.#1 to ^;
%end;
%mend loop;
%loop;
run;
quit;
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.