The SAS Output Delivery System and reporting techniques

How to create a link and an anchor using ODSOUT and ODS PDF

Reply
Super Contributor
Posts: 398

How to create a link and an anchor using ODSOUT and ODS PDF

Hello, I'm trying to create a link and anchor on a PDF file I'm trying to create.  I want to add a link where the ???? is in my code below.  I'm going to create my own table of contents and I want the links in my table of contents to point to the data that is produced from this code:

data _null_ ;

    set InfoVar ;

    by year vname ;

    if _n_ = 1 then declare odsout obj() ;

    if first.vname then do ;

        obj.table_start(overrides: 'frame=void rules=none ' ) ;

            obj.body_start() ;

                obj.row_start() ;

                    obj.format_cell(text: vname, column_span: 2,  overrides: "backgroundcolor=white just=left cellwidth=7in fontweight=bold font_face='Courier New' font_size=10pt ") ;                   

                    ???????????????????????????????????????? ;

                obj.row_end() ;               

    end ;       

   

    if last.vname then do ;       

        obj.body_end() ;

        obj.table_end() ;

    end ;

run ;

SAS Super FREQ
Posts: 8,722

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Hi:

  I am not sure you can create a link except at the beginning of a table. The place where you have a link is on a row. I really would recommend that you work with Tech Support on this question. For example, if I run this code, I get the links as I expect -- at the beginning of every table created by every DATA _NULL_ step. I am not sure how to put links "inside" the row. Note how the anchors or links, by default, are put only at the beginning of each step and for each table.
  

cynthia

ods pdf file='c:\temp\data_null.pdf'
    contents=yes;

ods proclabel 'First Report';
data _null_;
  set sashelp.class end=done;
  if _n_ eq 1 then do;
     declare odsout t();
     t.table_start();
       t.row_start();
         t.format_cell(text: 'Name');
         t.format_cell(text: 'Height');
         t.format_cell(text: 'Weight');
       t.row_end();
   end;
   t.row_start();
     t.format_cell(text: name);
     t.format_cell(text: height);
     t.format_cell(text: weight);
   t.row_end();
if done then t.table_end();
run;
 
ods proclabel 'Second Report';
data _null_;
  set sashelp.cars(obs=3) end=done;
  if _n_ eq 1 then do;
     declare odsout t();
     t.table_start();
       t.row_start();
         t.format_cell(text: 'Make');
         t.format_cell(text: 'Model');
         t.format_cell(text: 'MSRP');
       t.row_end();
   end;
   t.row_start();
     t.format_cell(text: make);
     t.format_cell(text: model);
     t.format_cell(text: msrp);
   t.row_end();
if done then t.table_end();
run;
ods _all_ close;

Super Contributor
Posts: 398

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Hi Cynthia, Thank you for your reply.  When I run this code I don't have any links on my PDF other then the bookmarks on the left side panel.  I did just put in a request to tech support.  I apologize for all my varying questions. Thank you for all your help.

SAS Super FREQ
Posts: 8,722

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Hi, yes that was the point of the example. I believe that you might put a link in a cell, but you need to know that every DATA _NULL_ step will come with automatic links. That may not be what you want to see. In order to build  those bookmarks, ODS uses "anchors" at the top of each table.

If you use an override for the URL style attribute in the PDF document, you will need to know the correct syntax to use for the cell link and you will need to know ahead of time whether you can link to an external document or link to a location within the same document. These are questions for Tech Support.

cynthia

SAS Employee
Posts: 2

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Hi Cynthia, could you share the file? data_null.pdf to prove the code.

thanks

SAS Super FREQ
Posts: 8,722

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Hi:

  You should be able to cut and paste the code yourself to see the results. I have attached a screen shot of the output, viewed in Adobe Acrobat Reader and showing the default bookmarks, the Table of Contents page and page 1 of the output. Basically before undertaking a change to the code for links, it is useful to understand the default behavior in regard to internal document links. So my program shows all the default links (bookmarks) that are created.

cynthia


result_data_step_pdf.png
SAS Employee
Posts: 2

Re: How to create a link and an anchor using ODSOUT and ODS PDF

Ok perfect, thanks!

Ask a Question
Discussion stats
  • 6 replies
  • 670 views
  • 2 likes
  • 3 in conversation