I have created a macro variable to hold a hyperlink:
%let CT_link = https://controller.vcu.edu/grants/;
I am using the PROC REPORT to generate the report. I try to embed that hyperlink into a block of text using the Line Statement:
line @1 'deadline ^{style [url="&ct_link" linkcolor=white]via the ^{style [color=blue textdecoration=underline]cost transfer form} available on the G&C webpage.} ';
We then have a parameter to specify if the report should be output as either PDF or EXCEL. When the report is written as PDF, the hyperlink works fine:
But when I export the report to EXCEL, the hyperlink does not work:
Is there a way to embed the hyperlink in a line of text to have it work both in PDF and EXCEL format?
This is the code that we include to allow selection between PDF, EXCEL or HTML:
data _null_;
if upcase("&outtype") = "HTML" then call symput("odsdest","HTML");
if upcase("&outtype") = "PDF" then do;
rc = stpsrv_header('Content-type','application/pdf');
rc = stpsrv_header('Content-disposition','attachment; filename=temp.pdf');
call symput("odsdest","PDF");
end;
if upcase("&outtype") = "EXCEL" then do;
rc = stpsrv_header('Content-type','application/vnd.ms-excel;');
rc = stpsrv_header('Content-disposition','attachment; filename=temp.xls');
call symput("odsdest","tagsets.excelxp");
end;
run;
Are you sure that is the code you ran?
line @1 'deadline ^{style [url="&ct_link" linkcolor=white]via
the ^{style [color=blue textdecoration=underline]cost transfer form}
available on the G&C webpage.} ';
Because the use of single quotes around the string will prevent the macro processor from replacing the reference to the CT_LINK macro variable with its value.
Try using double quotes instead.
line @1 "deadline ^{style [url='&ct_link' linkcolor=white]via
the ^{style [color=blue textdecoration=underline]cost transfer form}
available on the G&C webpage.} ";
It will also prevent the macro processor from replacing the reference to the C macro variable with its value. But you did not provide a value for that one.
In Excel file, the URL only can apply to a whole cell, not just a part of line .
Interesting thing is the URL seems to be unable to apply to LINE statement, I don't know why .
But FOOTNOTE could make a workaround way.
%let CT_link = https://controller.vcu.edu/grants/;
ods escapechar='^';
ods excel file='c:\temp\temp.xlsx' options(Sheet_Name='xx' Embedded_footnotes='yes');
footnote j=l link="&ct_link" 'deadline ^{style [textdecoration=underline color=blue]cost transfer form} available on the G&C webpage.' ;
proc report data=sashelp.class nowd;
run;
ods excel close;
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.