The SAS Output Delivery System and reporting techniques

Add Hyperlinks to each cell in a cross tabbed Proc Report

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Add Hyperlinks to each cell in a cross tabbed Proc Report

Hi,

 

I have the following proc report which is output to ODS HTML. Is it possible to use the groupings to build a hyperlink for each cell?

 

For example, when the user clicks on the cell that shows the Actual Sales for Country=Canada and Region=East, is it possible to have a link to an alreay created file named "CanadaEast.html" and when the user clicks on predicted sales USA west, link to "USAWest.html".

 

proc report data=sashelp.prdsale nowd out=abscols style(summary)=Header;

column country ( region,(actual predict )) ('Overall' actual=act predict=pred);

define country / group style(column)=Header;

define region / across;

define actual / sum format=comma12.;

define predict / sum format=comma12.;

define act / sum format=comma12. style(column)=Header;

define pred / sum format=comma12. style(column)=Header;

rbreak after / summarize;

run;

 

 

Thanks,

 

cxkev182


Accepted Solutions
Solution
‎09-08-2017 05:32 AM
PROC Star
Posts: 1,831

Re: Add Hyperlinks to each cell in a cross tabbed Proc Report

You normally have to click on the column header, but a bit of pre-processing allows this.

 


proc means data=SASHELP.PRDSALE nway noprint;
  class COUNTRY REGION;
  var   ACTUAL PREDICT ;
  output out=SUM sum=;
run;

data _F;
  retain TYPE 'N' FMTNAME 'LINKS';
  set SUM;
  START=ACTUAL ; LABEL=catt('<a href="',COUNTRY,REGION,'.htm">',ACTUAL ,'</a>'); output;
  START=PREDICT; LABEL=catt('<a href="',COUNTRY,REGION,'.htm">',PREDICT,'</a>'); output;
run;

proc format cntlin=_F; run;


ods html file="%sysfunc(pathname(work))\test.htm"  ;

proc report data=sashelp.prdsale nowd out=abscols style(summary)=Header;
  column country ( region,(actual predict )) ('Overall' actual=act predict=pred);
  define country / group style(column)=Header;
  define region / across;
  define actual / sum format=links. ;
  define predict / sum format=links.;
  define act / sum format=comma12. style(column)=Header;
  define pred / sum format=comma12. style(column)=Header;
  rbreak after / summarize;
run;
 
ods html close;

 

  Region  
  EAST WEST Overall
Country Actual Sales Predicted Sales Actual Sales Predicted Sales Actual Sales Predicted Sales
CANADA 127485 120646 119505 112373 246,990 233,019
GERMANY 124547 117579 121451 113975 245,998 231,554
U.S.A. 118229 120587 119120 121135 237,349 241,722
  370261 358812 360076 347483 730,337 706,295

 

You can check for duplicate values and add 0.00001 to differentiate between them if you want to be thorough.

 

 

 

View solution in original post


All Replies
Solution
‎09-08-2017 05:32 AM
PROC Star
Posts: 1,831

Re: Add Hyperlinks to each cell in a cross tabbed Proc Report

You normally have to click on the column header, but a bit of pre-processing allows this.

 


proc means data=SASHELP.PRDSALE nway noprint;
  class COUNTRY REGION;
  var   ACTUAL PREDICT ;
  output out=SUM sum=;
run;

data _F;
  retain TYPE 'N' FMTNAME 'LINKS';
  set SUM;
  START=ACTUAL ; LABEL=catt('<a href="',COUNTRY,REGION,'.htm">',ACTUAL ,'</a>'); output;
  START=PREDICT; LABEL=catt('<a href="',COUNTRY,REGION,'.htm">',PREDICT,'</a>'); output;
run;

proc format cntlin=_F; run;


ods html file="%sysfunc(pathname(work))\test.htm"  ;

proc report data=sashelp.prdsale nowd out=abscols style(summary)=Header;
  column country ( region,(actual predict )) ('Overall' actual=act predict=pred);
  define country / group style(column)=Header;
  define region / across;
  define actual / sum format=links. ;
  define predict / sum format=links.;
  define act / sum format=comma12. style(column)=Header;
  define pred / sum format=comma12. style(column)=Header;
  rbreak after / summarize;
run;
 
ods html close;

 

  Region  
  EAST WEST Overall
Country Actual Sales Predicted Sales Actual Sales Predicted Sales Actual Sales Predicted Sales
CANADA 127485 120646 119505 112373 246,990 233,019
GERMANY 124547 117579 121451 113975 245,998 231,554
U.S.A. 118229 120587 119120 121135 237,349 241,722
  370261 358812 360076 347483 730,337 706,295

 

You can check for duplicate values and add 0.00001 to differentiate between them if you want to be thorough.

 

 

 

Contributor
Posts: 25

Re: Add Hyperlinks to each cell in a cross tabbed Proc Report

Great, thanks for your help!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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