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

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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