DATA Step, Macro, Functions and more

ODS PDF bookmarks

Reply
New Contributor
Posts: 4

ODS PDF bookmarks

When creating ods pdf files for an analysis, is there a way to generate bookmarks for a paragraph of texts where there's no tables or graphs printed?

Frequent Contributor
Posts: 123

Re: ODS PDF bookmarks

[ Edited ]

It might depend on how you are adding the text.  If you use PROC ODSTEXT, you can create a bookmark with the ODS PROCLABEL statement.

 

Here's some example code.

 

options nodate;

ods pdf file='/folders/myfolders/SAS Communities/Bookmarks for PROC PRINT and PROC ODSTEXT.pdf'
  contents;

ods proclabel='Happy SAS University Edition user';

proc odstext contents='';
  h1 'Happy SAS University Edition user' / style=[just=c];
  p 'This is just some random text that I wrote to show up before the PROC PRINT output. 
User posted a question on SAS Communities asking if there is a way to add a PDF bookmark 
for paragraphs of text in the file that are NOT related to tables or graphics.  ';
  p 'I just updated my version of SAS University Edition at home to Release 3.71.  I really 
enjoy working with SAS University Edition, because it allows me to try out the new techniques 
and syntax while I wait for SAS to be upgraded at work.';
run;

ods proclabel='Major League Baseball players in Ohio in 1986';

proc print data=sashelp.baseball(where=(team in ('Cleveland','Cincinnati'))) noobs 
       contents='';
  title 'Major League Baseball data from 1986';
  var name team league division position;
run;

title;
ods pdf startpage=now; ods proclabel='Some thoughts on sports fans in Ohio'; proc odstext contents=''; h1 'Some thoughts on sports fans in Ohio' / style=[just=c]; p 'People who grow up in Northeast Ohio tend to be fans of the Cleveland Indians, while those who grow up near Cincinnati tend to be fans of the Cincinnati Reds. LeBron James is a notable example of a person who grew up in Northeast Ohio but preferred the New York Yankees.'; p 'People who grow up in Columbus generally pick between the Cleveland Indians and the Cincinnati Reds. Columbus is much more of a college football town, which is understandable, as it is home for The Ohio State University Buckeyes!'; run; ods pdf close;

The code produces a PDF with some text on one page, followed by a page with a table, followed by another page with some text.  

The screen shot below shows the bookmarks.

 

Bookmarks for PROC PRINT and PROC ODSTEXT.jpgODS PROCLABEL statement can create a bookmark for PROC ODSTEXT

New Contributor
Posts: 4

Re: ODS PDF bookmarks

Posted in reply to SuzanneDorinski

Nice. Thank you for your great help! 

 

However here's an issue with bookmarks -- when I click on a bookmark, I am not taken immediately to that line (which is what I would have expected when I click on a bookmark).  I am taken close to the spot but not quite to the spot, which is a bit annoying.  Any insight on how to resolve it or it is just how these bookmarks are built to do?

Frequent Contributor
Posts: 123

Re: ODS PDF bookmarks

I've seen the same thing with bookmarks created based on Word document headings.  I don't know if there's a better way.  Perhaps @Cynthia_sas may have some thoughts.

Super User
Posts: 13,941

Re: ODS PDF bookmarks


@yy2018 wrote:

Nice. Thank you for your great help! 

 

However here's an issue with bookmarks -- when I click on a bookmark, I am not taken immediately to that line (which is what I would have expected when I click on a bookmark).  I am taken close to the spot but not quite to the spot, which is a bit annoying.  Any insight on how to resolve it or it is just how these bookmarks are built to do?


Which PDF file viewer are you using? There might be some difference depending on the viewer.

 

Any you might need to share some code that you are using. Since we have no results to examine or any idea of how the document was generated you're going to get generic "might be this" answers. And without knowing how it was made it is hard to show even possible solutions.

 

As a minimum code examples should show ODS PDF (so we see all the PDF options applied) to the ODS PDF Close statements with one or more output generators that would duplicate the behavior you get. Ideally using supplied SAS data sets so we don't have make fake data or have you worry about sharing sensitive data.

Ask a Question
Discussion stats
  • 4 replies
  • 129 views
  • 0 likes
  • 3 in conversation