Help using Base SAS procedures

adding a hyperlink to RTF table output

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

adding a hyperlink to RTF table output

Hello,

I am creating a simple table in SAS and outputting in RTF format. The table has four columns: PROT SITE DIR COUNT. I want to assign a network directory path (e.g. a folder on my company's shared drive) to a value of DIR, then assign a hyperlink to that value with a label. The intent is to have output with click-able links that will take the user to the network path intended, rather than just displaying the raw network path as the value. I have done multiple searches and can only come up with solutions for adding hyperlinks in titles or footnotes.

Thanks,

Lucas


Accepted Solutions
Solution
‎01-05-2015 01:58 PM
Super Contributor
Posts: 394

Re: adding a hyperlink to RTF table output

This example uses PROC REPORT. It calls the DEFINE subroutine to add a hyperlink to each value of "name". (The hyperlinks are bogus, of course.)

data;

   set sashelp.class;

  url = "http://www.sas.com";

run;

ods listing close;

ods rtf file="hyperlink.html";

proc report nowd;

col url name;

define url /noprint;

define name /display;

compute name;

    call define(_col_, "url", url || "/" || name);

endcomp;

run;

ods listing;

ods rtf close;

View solution in original post


All Replies
Solution
‎01-05-2015 01:58 PM
Super Contributor
Posts: 394

Re: adding a hyperlink to RTF table output

This example uses PROC REPORT. It calls the DEFINE subroutine to add a hyperlink to each value of "name". (The hyperlinks are bogus, of course.)

data;

   set sashelp.class;

  url = "http://www.sas.com";

run;

ods listing close;

ods rtf file="hyperlink.html";

proc report nowd;

col url name;

define url /noprint;

define name /display;

compute name;

    call define(_col_, "url", url || "/" || name);

endcomp;

run;

ods listing;

ods rtf close;

Occasional Contributor
Posts: 14

Re: adding a hyperlink to RTF table output

Thanks Tim. This works when I run your sample code, but when I try to apply it to my code I get the following error:

ERROR: Unrecognized attribute name in CALL DEFINE.

NOTE: Argument 2 to function DEFINE at line 1 column 7 is invalid.

NOTE: There were 1 observations read from the data set WORK.RENPENUP3.

My code is:

ods listing close;

ods rtf file='[file path]';

title [title];

proc report data=renpenup3 nowd;

col dir site;

define dir /noprint;

define site /display;

compute site;

    call define(_col_, "dir", dir || "/");

    endcomp;

    run;

ods listing;

ods rtf close;

The renpenup3 data set I am reading from contains:

PROT | SITE | DIR | COUNT

XXX01 | XXX02 | [location of file on my drive] 1

I should note value of DIR is generated from a macro.

Thanks,

Lucas

SAS Super FREQ
Posts: 8,683

Re: adding a hyperlink to RTF table output

Hi:

  The second argument to the CALL DEFINE statement cannot be "dir" -- it can only be "format", "style", or as Tim showed you: "url" -- it is the second argument that tells CALL DEFINE what type of change it is about to make.

cynthia

Occasional Contributor
Posts: 14

Re: adding a hyperlink to RTF table output

Ah, thank you Cynthia. I was confused about same name for variable and argument. It is working now.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 306 views
  • 3 likes
  • 3 in conversation