Adding pop-up graphs to your SAS/GRAPHs


By now, most of you probably already know how to add drill downs and hover text to your SAS graphs.  But did you know you can add pop-up images and graphs?

Here are a couple of examples ...

In this first example, when you hover your mouse over each state, you should see an image of that state's quarter.  (Note: you'll have to click on the image below first, to view the interactive sample.)

In the second example, when you hover over the states, each state's image is a bar chart showing the population trend for that state over time.  Note that all of the bar charts were also created using SAS/GRAPH (again, click the image below to view the interactive page):

"How did you do that?" you might ask...

In addition to the HTML href= drilldown, and title= text, I'm using OnMouseOver= to call a custom javascript function to display the images in a pop-up window.

If you have pop-ups disabled, you might have to temporarily enable them to view the pop-ups.  For example, in Internet Explorer you might temporarily allow pop-ups by also hitting the Ctrl key for the first state you mouse.  Once the pop-ups are allowed, then you don't have to hold down the Ctrl key any more.

How does the code work?  In the ODS statement, I specify the 'no_bottom_matter' option, and then at the bottom of the sas job, I use a filename with the 'mod' option to modify the generated html, and then append the custom javascript to the bottom using sas 'put' statements.  Note that I'm no javascript expert and you don't have to be one to reuse this code!

Here are links to the actual code for the first and second sample.

So ... what do you plan to do with this trick?!?  :-)


About Author

Robert Allison

The Graph Guy!

Robert has worked at SAS for over a quarter century, and his specialty is customizing graphs and maps - adding those little extra touches that help them answer your questions at a glance. His educational background is in Computer Science, and he holds a BS, MS, and PhD from NC State University.

Related Posts


  1. This is great.
    I actually copied this from your site some months ago and I am using it on a table grid rather than a map.
    Users like not having to drill into some other page.

  2. jennifer cowley on

    Hello Robert,
    Neat work! I saw this posted on Facebook and decided to investigate. Low and behold it was you and your brilliant work. Keep it up!

  3. Interesting.

    Sometimes I get extra popup windows. For example, I carefully hovered only over FL and got 3 FL windows. I think at one point I had 6 popup windows (not with identical states).

    • Robert Allison

      Yep - unfortunately with javascript, it's difficult to get things to run exactly the same in every browser on every platform. Currently I'm using Internet Explorer 9 on Windows 7 Enterprise, and the popup images are working 'perfect' for me ... but in the past in some other browser/version/platform (I can't remember which one(s)) I occasionally saw the multiple images popping-up. I'm not sure if it's a "fixable" problem.

Leave A Reply

Back to Top