BookmarkSubscribeRSS Feed
RobW
Calcite | Level 5
I've thoroughly confused myself, and I am sure there will be a simple answer. I've created a summary report where I want to have 'hyperlinks' for certain cell counts to drilldown sheets within the same file. So, if this was a simple 1x1 table with a single count reported, there would be two sheets - one for the summary 1x1 tables and another for the drilldown of corresponding data contributing to that count.

I'm having trouble creating the link using the ExcelXP tagset. should I be using HREF? is there a tagattr for internal file destinations?

I foresee a palm to the forehead gesture when I get the answer 😜
4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
In general, the way to set hyperlinks with ODS is through the use of:
1) URL= style attribute
2) with PROC REPORT, using the CALL DEFINE statement with the URL option
3) for ODS HTML, only, coding the proper <A> tag

TAGATTR is limited to setting formats, formulas and types, when you use the ExcelXP tagset. I have used the URL= style attribute with TAGSETS.EXCELXP without any issues. You do need to know what your sheets will be named in order to be able to build the format that you need.

For example, I have my first sheet called, Main; a second sheet called Asia and a third sheet called Canada. I set those using the sheet_name option in TAGSETS.EXCELXP suboption list (as shown below).

Now that I know the names of my sheets, I can make a user defined format that will give Excel the proper "link" syntax it wants. Excel doesn't really want a fully qualified hyperlink, this seems to be the form of link that it uses:
[pre]
#SheetName!A1
[/pre]

Next, I built a user-defined format like this:
[pre]
proc format ;
value $reglnk 'Asia'= '#Asia!A1'
'Canada' = '#Canada!A1';
run;
[/pre]

Finally, I used the user-defined format here:
[pre]
define region / group
style(column)={url=$reglnk.};
[/pre]

I show a PROC REPORT example, but you could use similar syntax with PROC TABULATE or PROC PRINT or even with a custom Table Template. The full program is below.

cynthia

[pre]
proc format ;
value $reglnk 'Asia'= '#Asia!A1'
'Canada' = '#Canada!A1';
run;

ods tagsets.excelxp file='c:\temp\try_hyper.xml' style=sasweb
options(sheet_name='Main');

proc report data=sashelp.shoes nowd ;
column region product sales;
where region in ('Asia', 'Canada');
define region / group
style(column)={url=$reglnk.};
define product / group;
define sales / sum;
rbreak after / summarize;
run;

ods tagsets.excelxp options(sheet_name='Asia') ;

proc report data=sashelp.shoes nowd ;
column region product sales;
where region = 'Asia';
define region / display;
define product / display;
define sales / sum;
rbreak after / summarize;
run;

ods tagsets.excelxp options(sheet_name='Canada');

proc report data=sashelp.shoes nowd ;
column region product sales;
where region = 'Canada';
define region / display;
define product / display;
define sales / sum;
rbreak after / summarize;
run;

ods tagsets.excelxp close;
[/pre]
anandbillava
Fluorite | Level 6

I have used this option in the past and it was working for me. Recently I am using a new instance of SAS in a new company and its not working. Is there anything to do with SAS options.? I am using SAS 9.4 M7 PC SAS.

Tom
Super User Tom
Super User

@anandbillava wrote:

I have used this option in the past and it was working for me. Recently I am using a new instance of SAS in a new company and its not working. Is there anything to do with SAS options.? I am using SAS 9.4 M7 PC SAS.


Provide a minimal reproducible example program that others can run.

That is provide a data step that creates enough data and the code to create an XML file where the hyperlinks do not work for you.

Chevell_sas
SAS Employee

Is the issue that the hyperlinks are not working or is the file not opening in Excel?

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
  • 4 replies
  • 2958 views
  • 1 like
  • 5 in conversation