Data visualization with SAS programming

How to make the Drill-Down Graph work in PDF file?

Reply
Super Contributor
Posts: 1,636

How to make the Drill-Down Graph work in PDF file?

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="&region..htm" path=odsout style=listing;

/* Set the axis label and title */

axis1 label=("Total Sales");

title1 "Total Sales in &region Region";

/* Create the chart */

proc gchart data=regsales;

vbar3d state / sumvar=sales outside=sum name="region"

raxis=axis1 patternid=midpoint

description="Total sales for &region region"

shape=cylinder width=15;

where region="&region";

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;

Esteemed Advisor
Posts: 7,290

Re: How to make the Drill-Down Graph work in PDF file?

Not sure what you meant by "(not in SAS)",  I just ran your code and the resulting pdf file had clickable links.

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

Would you please try to find the PDF file on your omputer then click from there?

Grand Advisor
Posts: 17,325

Re: How to make the Drill-Down Graph work in PDF file?

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...

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

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?

Grand Advisor
Posts: 17,325

Re: How to make the Drill-Down Graph work in PDF file?

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.

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

Art,

Please email me your PDF file with clickable links. Thank you!

SAS Employee
Posts: 967

Re: How to make the Drill-Down Graph work in PDF file?

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:

http://robslink.com/SAS/democd23/pdf_drill_info.htm

SAS Employee
Posts: 967

Re: How to make the Drill-Down Graph work in PDF file?

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)

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

I have PC sas9.3. I just double click the PDF file. Thank you!

SAS Employee
Posts: 967

Re: How to make the Drill-Down Graph work in PDF file?

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.

Grand Advisor
Posts: 17,325

Re: How to make the Drill-Down Graph work in PDF file?

In your final document will the links be to external websites or to other graphics/info?

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

Thank you Reeza! I am not sure at this point, I need more information. Have a great weekend! - Linlin

Respected Advisor
Posts: 3,124

Re: How to make the Drill-Down Graph work in PDF file?

Hi and other experts,

Do you happen to know anyway to create a PDF (or HTML for that matter) that supports 2+ level of click through? For example in your case, how do you make the HTM files click-able to get to the more granular level of data (if there are)?

Thanks,

Haikuo

Super Contributor
Posts: 1,636

Re: How to make the Drill-Down Graph work in PDF file?

Sorry Haikuo:smileysilly:, I don't know. Art, Robert, or Reeza may know.

Ask a Question
Discussion stats
  • 18 replies
  • 874 views
  • 6 likes
  • 5 in conversation