In SAS 9 and later, the ANCHOR= option on the ODS PDF statement inserts anchors into an ODS PDF output file. You can use PROC REPORT with CALL DEFINE to automate the process of linking to the anchored pages.
The sample code in the Full Code section creates a PDF file with links to the PACIFIC and CANADA detail pages. Please note that the capitalization of the ANCHOR= values can affect the functionality. See SAS Note 37323 for additional information.
See also SAS KB0041847 for additional information about links in the ODS PDF destination.
Full Code
The sample code creates a PDF file with links to the PACIFIC and CANADA detail pages. Please note that the capitalization of the ANCHOR= values can affect the functionality. See SAS Note 37323 for additional information.
proc template;
define style mystyle;
parent=styles.sasdocprinter;
/* TEXT= is left justified by
default. I'd like it centered */
style usertext from note /
just=c;
/* I want PAGEOF information too */
style PageNo from TitlesAndFooters /
font_weight=medium
pretext = "Page "
posttext = " of ^{lastpage}";
end;
run;
title;
/* close the OUTPUT window */
ods listing close;
options orientation=portrait center nodate;
ods escapechar="^";
ods pdf file="file.pdf" startpage=no style=mystyle;
ods pdf text="Click on a highlighted REGION to see details";
ods proclabel="SASHELP.SHOES";
proc report nowd data=sashelp.shoes contents="LINKS Page";
col region sales ;
define region / group;
compute region;
/* for purposes of illustration, we are linking
to 2 regions on later pages in this PDF file */
if region in ("Pacific","Canada") then do;
urlstring="#"||lowcase(left(region));
call define('_c1_','url',urlstring);
end;
endcomp;
run;
/* create a "footnote" that is placed close to the
REPORT table */
ods pdf text="^2n Prepared on: &sysdate9." ;
/* create an ANCHOR to point to the CANADA page
STARTPAGE= forces this onto a new page
COLUMNS= makes a 2 column page */
ods pdf anchor="canada" startpage=now columns=2;
title "Canada";
ods proclabel="Canada";
proc report data=sashelp.shoes(where=(region="Canada")) nowd contents="";
col subsidiary product sales;
define subsidiary / group;
define product / group;
rbreak after / summarize;
run;
ods pdf anchor="pacific" startpage=now;
title "Pacific";
ods proclabel="Pacific";
proc report data=sashelp.shoes(where=(region="Pacific")) nowd contents="";
col subsidiary product sales;
define subsidiary / group;
define product / group;
rbreak after / summarize;
run;
ods pdf close;