Hi Experts, I copied the below example from SAS/GRAPG 9.3 reference. Why “Click a bar for details” does not work in file ‘salesrpt_single_page.pdf’ (not through SAS) ?
Thank you!
/* Example: Writing a Drill-Down Graph to a PDF File */
/* Define the PDF output filename. */
filename outp "salesrpt_single_page.pdf";
/* Define the ODS output path. */
filename odsout ".";
/* Define the base URL for the links. */
%let baseurl=.;
/* Create the data set REGSALES. */
data regsales;
length Region State $ 8 Location $ 15;
format Sales dollar8.;
input State Region Location Sales;
datalines;
IL Central EVANSTON 18038
IL Central CHICAGO 14322
IL Central AURORA 10768
OH Central COLUMBUS 13611
OH Central DAYTON 11084
OH Central CINCINNATI 19534
FL South MIAMI 14541
FL South TAMPA 16733
NC South RALEIGH 19022
NC South WILMINGTON 12876
NC South CHARLOTTE 13498
CA West SANTA-CRUZ 13636
CA West LONG-BEACH 15687
WA West SEATTLE 18988
WA West TACOMA 14523
;
/* Add the link information to the data. */
data regsales;
set regsales;
length RPTR $ 80;
if (Region="Central") then RPTR="&baseurl./Central.htm";
else if (Region="South") then RPTR="&baseurl./South.htm";
else if (Region="West") then RPTR="&baseurl./West.htm";
else RPTR=.;
run;
/* Close the HTML destination and set the graphics options. */
ods html close;
goptions reset=all device=png border xpixels=520 ypixels=450;
/* Clear titles and footnotes */
title;
footnote;
/* Create a macro to use for generating the region charts. */
%macro do_region(region);
/* Open ODS HTML destination. Use the region name as the filename */
ods html file="®ion..htm" path=odsout style=listing;
/* Set the axis label and title */
axis1 label=("Total Sales");
title1 "Total Sales in ®ion Region";
/* Create the chart */
proc gchart data=regsales;
vbar3d state / sumvar=sales outside=sum name="region"
raxis=axis1 patternid=midpoint
description="Total sales for ®ion region"
shape=cylinder width=15;
where region="®ion";
run; quit;
/* Close the ODS HTML destination */
ods html close;
%mend do_region;
/* Call the %DO_REGION macro for Central, South, and West. */
%do_region(Central);
%do_region(South);
%do_region(West);
/* Open the PDF destination and set the style. */
ods pdf style=statistical;
/* Set the graphics options. You must use the PDF or PDFA device. */
goptions reset=all gsfname=outp device=pdf border
vorigin=2.5in horigin=0.6in vsize=550pt hsize=520pt;
/* Generate the Company Sales report PDF document. */
title1 "Company Sales Report";
title2 "Sales by Region";
footnote1 "(Click a bar for details.)";
axis1 label=("Total Sales") reflabel=(j=r "Target ");
proc gchart data=regsales;
vbar3d region /
cref=red lref=3 ref=62000 /* Draw a reference line at the */
/* sales target. */
sumvar=sales outside=sum raxis=axis1
shape=cylinder width=15 patternid=midpoint
description="Company sales report"
url=RPTR; /* Specify RPT as the URL variable in the data. */
run; quit;
/* Close the PDF destination and open HTML */
ods pdf close;
ods html;
/* Reset graphics options, titles, and footnotes */
goptions reset=all;
title;
footnote;
Not sure what you meant by "(not in SAS)", I just ran your code and the resulting pdf file had clickable links.
Would you please try to find the PDF file on your omputer then click from there?
The output file created was called sasprt (just ran the code above) which seems a bit weird but the links work fine. My only issue was I did get a warning in my browser about links activex content being blocked, so your browser settings could be something to look into.
EDIT: The report you mention does exist, just not the first one I saw. The links in that one DO NOT work. The links in the other one do...
Do you need to modify the code if you are going to email the PDF file to someone who doesn’t have sas? Are the links still clickable?
The links are to pages outside the document, separate html/png files, which would need to be emailed as well.
A person with SAS can open the file, but personally, I wouldn't go down this route because its difficult to package and help people when something is broken.
Art,
Please email me your PDF file with clickable links. Thank you!
Here is some pdf output from one of my SAS jobs, with drilldowns, if you want to try viewing that:
http://robslink.com/SAS/democd23/pdf_drill.pdf
And here is the SAS code I used, in case that might help:
Which version of SAS are you using?
(drilldown in pdf is a fairly new feature - I believe it's only available in SAS 9.3 and higher)
And how are you viewing the pdf?
(for example, I'm viewing it in the IE browser, on a Windows computer)
I have PC sas9.3. I just double click the PDF file. Thank you!
With my pdf, when I double-click the pdf in Windows Explorer, it comes up in Adobe Reader (is that what your PC is configured to use? - this could vary from PC to PC), and when I click the bars there the drilldowns work - it asks me if I want to allow or block, and when I allow, it pops up an IE browser window with the drilldown page (IE is my default web browser, but this could also be different on your PC).
When I view the pdf in IE (such as the url/link I posted a few minutes ago), then when I click the bars it goes to the drilldown url directly in that IE browser.
In your final document will the links be to external websites or to other graphics/info?
Thank you Reeza! I am not sure at this point, I need more information. Have a great weekend! - Linlin
Sorry Haikuo:smileysilly:, I don't know. Art, Robert, or Reeza may know.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.