BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Patrick
Opal | Level 21

I'm trying to generate an Excel workbook with hyperlinks from a cell in one sheet to a cell in another sheet.

 

In below self-contained sample: What am I missing? 

Why does this work with a hard-coded value but not when using variable C1ToC2_ref which got the correct value but appears to be missing at the time when I want to use it in the compute block.

 

%let excel_file=c:\test\test_linking.xlsx;

data class_1 class_2(drop=C1ToC2_ref);
  set sashelp.class;
  C1ToC2_ref=cats('#class_2!A',_n_);
run;

ods _all_ close;

ods escapechar='^';
ods excel file="&excel_file" 
  options(
  frozen_headers="1"
  frozen_rowheaders="1"
  sheet_interval='none'
  );

ods excel options(sheet_name="class_1" sheet_interval='now');

proc report data=class_1;
  compute name;
/*    urlstring = "#class_2!A3";*/
    urlstring = C1ToC2_ref;
    if not missing(urlstring) then
      do;
        call define(_col_, 'url',urlstring);
        call define(_col_, 'style', 'style={textdecoration=underline color=blue}');
      end;
  endcomp;
run;

ods excel options(sheet_name="class_2" sheet_interval='now');
proc report data=class_2;
run;

ods excel close;
ods listing;

What I want is an Excel workbook that when I click in sheet class_1 on Alice it takes me to sheet class_2cell A3

 

Patrick_0-1675079280473.png     -> Patrick_1-1675079317943.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

I think you need to put 

C1ToC2_ref

in the column statement before NAME. 

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19

I think you need to put 

C1ToC2_ref

in the column statement before NAME. 

Patrick
Opal | Level 21

Ooooh! Variable order matters! Yep, that did the trick.

Patrick_0-1675117825245.png

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1280 views
  • 0 likes
  • 2 in conversation