BookmarkSubscribeRSS Feed
Venkat4
Quartz | Level 8

I am trying to create a PDF file using ODS PDF containing proc report. This proc report is within a macro having 2 parameters for different employee. One of the columns uses format= option where the format obtained from a dataset having a column with the href text as below.

 

I am using this in the proc sql to obtain the dynamic hyperlink format

"<a href='R"||trim(left(put(id,3.)))||".pdf'>"||trim(left(put(id,3.)))||'-'||trim(left(projname))||' ['||trim(left(status))||']'||"</a>" as label

 

ODS HTML shows fine with the hyperlink. However, using the same code with ODS PDF the hyperlink does not show up, instead I see the actual text/tags like this:

<a href='abc.pdf'> The ABC PDF file </a>

 

How can I get the PDF to show the hyperlink within each row for the entire column. The hyperlink is basically the pdf files stored in previous steps. I remember doing similar kind long time ago, but can't able to wrap my head around to figure this out googling.

 

can someone please help? Thanks.

2 REPLIES 2
Ksharp
Super User
ods pdf file='/folders/myfolders/x.pdf';
proc report data=sashelp.class nowd;
column name sex age;
define age/display;
compute age;
 if age=11 then call define(_col_,'url','/folders/myfolders/test.pdf');
endcomp;
run;
ods pdf close;
Cynthia_sas
SAS Super FREQ

Hi:

  ODS PDF uses the URL style attribute as shown in Ksharp's example. PDF uses a "plain" URL, and doesn't use an <A> tag like HTML. Here's another couple of examples that illustrate how to create a "fixed" URL link (as for the NAME column header) that goes to www.google.com and then how to make a dynamic URL, such as for each value for name where the URL is:

https://www.google.com/#q=?????? , where ????? is replaced with the name for each row.

 

cynthia

 

** method 1;
proc format;
  value $urlnm 'Alfred'='https://www.google.com/#q=Alfred'
               'Alice'='https://www.google.com/#q=Alice'
	       'Barbara'='https://www.google.com/#q=Barbara'
               other = 'http://www.sas.com';
run;

ods pdf file='c:\temp\url1.pdf' notoc;

proc report data=sashelp.class;
  column name age height weight;
  define name / order 'Click for the Name'
     style(header)={url='http://www.google.com'}
     style(column)={url=$urlnm.};
run;
ods pdf close;


** method 2;
ods pdf file='c:\temp\url2.pdf' notoc;

proc report data=sashelp.class;
  column name age height weight;
  define name / order 'Click for the Name'
     style(header)={url='http://www.google.com'};

  compute name;
    length uvar $100;
	uvar=catt('https://www.google.com/#q=',name);
    call define(_col_,'url',uvar);
  endcomp;
run;
ods pdf close;

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
  • 2 replies
  • 1822 views
  • 2 likes
  • 3 in conversation