BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9

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 ;

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

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;

jerry898969
Pyrite | Level 9

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.

Cynthia_sas
SAS Super FREQ

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

Raquelgv
SAS Employee

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

thanks

Cynthia_sas
SAS Super FREQ

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-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1604 views
  • 2 likes
  • 3 in conversation