BookmarkSubscribeRSS Feed
renee_njc
Fluorite | Level 6

When creating the printable TOC page in PDF, there is a hyperlink in the TOC title. 

I tried to update the proc template but it doesn't work. 

Is there any way to remove the hyperlink from the TOC title?

 

Thanks!


My code for creating the PDF file is:

 

proc template;
define style stlpdfx;
parent=styles.pearl;

class ContentTitle from ContentTitle /
fontweight = bold
color=dark blue
margintop=12pt
pretext='My Customized Title'
;


end;
run;


ods _all_ close;
options pageno=2;
ods pdf file="&outdir./testfile.pdf" style=stlpdfx contents = yes;

proc document name=tfl.file1;
replay;
run;

 

proc document name=tfl.file2;
replay;
run;
quit;
ods pdf close;
ODS LISTING;

8 REPLIES 8
SASJedi
Ammonite | Level 13

Please show the SAS code for the step that produced the document files (tfl.file1 and tfl.file2). It is most probable that this is the code that inserted the hyperlink. 

 

Check out my Jedi SAS Tricks for SAS Users
renee_njc
Fluorite | Level 6

The code I used is blow:

/*Create table and save it to ods document as temp file*/
ods document name=work.temp(write) ;
ods listing close;
 
proc report data=tfl.file1 nowd headline center missing split='^' spacing=0 contents="";
by pg;
column pg ord1-ord4 col0 col0_1 col1-col3 margin;
 
define pg/ order noprint;
define ord1/ order=internal noprint;
define ord2/ order=internal noprint;
define ord3/ order=internal noprint;
define ord4/ order=internal noprint;
define col0 / display "Disposition" style(header)=[just=left] style(column)=[just=left cellwidth=4.5in] flow;
define col0_1 / display "Statistic" style(header)=[just=left] style(column)=[just=left cellwidth=.7in] flow;
define col1 / display "A" style(header)=[just=c] style(column)=[just=c cellwidth=1in] flow;
define col2 / display "B" style(header)=[just=c] style(column)=[just=c cellwidth=1in] flow;
define col3 / display "Total" style(header)=[just=c] style(column)=[just=c cellwidth=1in] flow;
define margin/ display noprint;
 
break before pg / page contents="";
 
compute margin;
if margin=1 then call define("col0", "style", "style=[leftmargin=.14in]");
if margin=2 then call define("col0", "style", "style=[leftmargin=.28in]");
endcomp;
 
%long_foot;
 
run;
 
ods document close;
 
ods listing;
 
/*Keep bookmark in the first page only.*/
 
%global tpg;
%macro doc;
proc document; 
doc; 
doc name = work.temp; 
list/levels=all;
run;
quit; 
%if &tt4. ne %then %do;
proc document name=work.temp(update); 
make \first;dir \first#1; 
setlabel\first#1 "%sysfunc(strip(&tt1)) %sysfunc(strip(&tt2)) %sysfunc(strip(&tt3)) - %sysfunc(strip(&tt4))";
  %do z=1 %to &tpg.; copy \Report#1\ByGroup&z.#1\Report#1 to ^; %end; 
run;
quit;
%end;
%else %do;
proc document name=work.temp(update); 
make \first;dir \first#1; 
setlabel\first#1 "%sysfunc(strip(&tt1)) %sysfunc(strip(&tt2)) - %sysfunc(strip(&tt3))";
  %do z=1 %to &tpg.; copy \Report#1\ByGroup&z.#1\Report#1 to ^; %end; 
run;
quit;
%end;
 
%symdel tt1 tt2 tt3 tt4;
 
%mend doc;
%doc;
 
ods listing close;
 
/*Output table*/
ods document name=tfl.&outfile.(write) ;
ods rtf file="&outdir./file1.rtf" style=stlrtf startpage=yes;
ods pdf file="&outdir./file1.pdf" style=stlpdf startpage=yes;
proc document name=work.temp(update);
 replay\first ; run; quit; 
 
ods _all_ close;
 
The file2 was created using the same code but different dataset. 
 
Thanks.
Tom
Super User Tom
Super User

What does the Hyperlink link to?

What code does your %LONG_FOOT macro produce?

 

Can you recreate the issue without all of the macro code?

If not the eliminate the macro code by first running with the MPRINT option turned on (or perhaps even the MFILE option) and try running the generated code in a new session.

 

Now that you have the actual code try making it simpler.  Replace your complicate PROC REPORT with something simpler.  Perhaps something as simple as :

proc report data=sashelp.class(obs=10);
run;

Do you still get the hyperlink?

 

renee_njc
Fluorite | Level 6

The hyperlink in the "Table of Contents" is linked to the first file. 
I tried the simple code and the hyperlink still exists. 

%let outdir = C:/User/temp;
ods pdf file="&outdir./test.pdf" style=stlpdf contents = yes ;

proc report data=sashelp.class(obs=10);
run;

proc report data=sashelp.class(obs=20);
run;
ods pdf close;
Tom
Super User Tom
Super User

Isn't that the point of a table of contents?

They are not links to external files, they are links to locations with this file where the item listed in the table of contents can be found.

Is there a reason why they cause problems?

renee_njc
Fluorite | Level 6

Yes, so I am ok with the hyperlink in the contents of TOC (the red part in the screenshot).

I want to remove the hyperlink from the words of "Table on Contents" (the yellow part in the screenshot).

renee_njc_1-1740536115120.png

Is there any way to do that? 

 

Tom
Super User Tom
Super User

That does seem stupid.  It it linked anywhere it should be the page it is already on.

You try seeing if you can do it with CSS style changes?

If you add the DOM option to your ODS PDF it will print the CSS it is generating to the SAS log.

Looks your might be able to use CSS to change this element??

      <p class="contenttitle" url="idx">
      </p>
renee_njc
Fluorite | Level 6

Hi Tom, 

I tried the CSS style and it doesn't work.

The hyperlink is still there.

Here is my CSS style:

 

.body, .systemtitle, .header, .data {
   font-family: Courier New;
   }
   .body {
   color: black;
   background-color: white;
   border: solid black 0.1px;
   margin-bottom: 0.77in;
   margin-left: 1.34in;
   margin-right: 1.34in;
   margin-top: 0.77in;
   }

   .data
   {
     color: black;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     border-width: 0.1em 0 0.1pt 0;
   }   
   .table
   {
     background-color: #FFFFFF;
     border-collapse: collapse;
     border-bottom-width: 0.1pt;
     border-collapse: separate;
     border-color: none;
     border-left-width: 0px;
     border-right-width: 0px;
     border-spacing: 0pt;
     border-style: solid;
     border-top-width: 0.1pt;  
     color: black;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     text-align: center;
     margin-bottom: 0.77in;
     margin-left: 1.34in;
     margin-right: 1.34in;
     margin-top: 0.77in;
   }
   .header
   {
    border-collapse: collapse;
    border-bottom-width: 0.1pt;
    border-collapse: separate;
    border-color: none;
    border-left-width: 0px;
    border-right-width: 0px;
    border-spacing: 0pt;
    border-style: solid;
    border-top-width: 0.1pt; 
     background-color: #FFFFFF;
     color: #000000;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
   }    

   .systemtitle 
   {
   color: #000000;
   font-family: 'Courier New';
   font-size: 9pt;
   font-style: normal;
   font-weight: normal;
   background-color: none; 
   }
    .systemfooter
   {
     background-color: #FFFFFF;
     color: #000000;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
   }
     
   .contents
   {
     background-color: #FFFFFF;
     color: blue;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     list-style-type: decimal;
     margin-left: 0px;
     margin-right: 0px;
   }

   .contents
{
  list-style-type: square;
  pointer-events: none;
}


   .contenttitle
   {
     color: green;
     font-family: 'Courier New';
     font-size: 12pt;
     font-style: normal;
     font-weight: bold;
     margin-bottom: 4em;
     margin-left: 1em;
     margin-right: 1em;
     margin-top: 4em;
     text-align: center;
     width: 100%;
     background-color:aqua; 
     pointer-events: none;
    }
  
  .contentproclabel
   {
     color: blue;
     font-family: 'Courier New';
     font-size: 8pt;
     font-style: normal;
     font-weight: normal;
     list-style-type: decimal;
     margin-left: 0in;
     margin-right: 0in;
   }
   .contentitem
   {
     color: red;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     list-style-type: none;
     margin-left: 15%;
     margin-right: 15%;
   }
   
   .contentfolder
   {
     color: purple;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     list-style-type: none;
     margin-left: 15%;
     margin-right: 15%;
   }
   .usertext
   {
     background-color: #FFFFFF;
     color: yellow;
     font-family: 'Courier New';
     font-size: 9pt;
     font-style: normal;
     font-weight: normal;
     pointer-events: none;
   }

Here is my SAS code to generate the output:

filename ncss "mypath./testt.css";
proc template;
define style styles.mycssstyle;
    import ncss;

end;
define style styles.mycssstyleprinter;
        parent=styles.mycssstyle;
        import ncss print;
        class contenttitle/  
          pretext = "TAT";

end;
run;


ods pdf file="&outdir./test.pdf" style=styles.mycssstyleprinter contents = yes ;


ods proclabel = "TEST1";
title   "test1";
proc report data=sashelp.class(obs=10);

run;

ods proclabel = "TEST2";
title   "test2";
proc report data=sashelp.class(obs=20);
run;
ods _all_ close;

ods pdf file="&outdir./test.pdf" style=styles.mycssstyleprinter contents = yes ;


ods proclabel = "TEST1";
title   "test1";
proc report data=sashelp.class(obs=10);

run;

ods proclabel = "TEST2";
title   "test2";
proc report data=sashelp.class(obs=20);
run;
ods _all_ close;

I have tried the code you posted. It doesn't work either. 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2402 views
  • 3 likes
  • 3 in conversation