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
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;
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;
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
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
Ah, thank you Cynthia. I was confused about same name for variable and argument. It is working now.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.