BookmarkSubscribeRSS Feed
DonH
Lapis Lazuli | Level 10
I need to be able to produce reports in EG that have pop-ups for text items that contain additional information. Actually the user I am building this for wants this for output data sets - I am pretty sure that is not possible - but I can do it with an HTML table. I have found a number of resources that allow me to do that using span tags, combined with CSS styles and some simple JavaScript. If I was doing this by coding my own ODS HTML statement I would simply use the headtext option. My question is how to best do this in EG? Based on some preliminary option it appears that the only option EG provides is to provide a custom style using the Manage Styles button in Options -> Results -> HTML.

Alternatively I might be able to package the code as a Stored Process where I have more control over HTML generation. This is only an option if the output data set created by the Stored Process can be linked to other code nodes in EG.

TIA for any advice/suggestions.
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Don:
If you search on the SAS site for "ODS HTML Javascript", you should find some Tech Support notes that talk about inserting JavaScript into ODS output (which would mean that you would not have to code all the HTML yourself):
http://support.sas.com/kb/23/645.html
http://support.sas.com/kb/23/381.html
http://support.sas.com/kb/?qm=3&la=en&ct=51012&qt=subject:%22javascript_1%22+

You can use a custom CSS file with ODS HTML -- either in or outside of EG -- EG just uses the STYLESHEET= option. The trick would be to make sure that your custom CSS file is in the right place on the server so it could be used when you want it to be used. You'd have this same issue (where does the style template live) if you used SAS style templates to insert the JavaScript (instead of CSS), as described here:
http://support.sas.com/kb/4/773.html

Also as far as popups go, you can use the FLYOVER style attribute with ODS HTML to turn on popup windows. When you hover your mouse over the F or M, you should see a popup window with extra text.

[pre]
proc format;
value $gend 'M' = 'Something for male students'
'F' = 'Different for female students';
run;

title; footnote;
options nodate nonumber;
ods listing close;

ods html file="c:\temp\show_flyover.html" style=sasweb;

proc print data=sashelp.class;
title 'Use FLYOVER in variable cells based on variable value';
var name age height;
var sex / style(data)={flyover=$gend.};
run;

ods html close;
[/pre]

To see an example of using CSS and lots of popup windows, look at this example:
[pre]

ods markup tagset=style_popup path='c:\temp' (url=none)
file='popup.html' style=sasweb
stylesheet='popup.css';

proc report data=sashelp.shoes nowd;
column region sales inventory returns;
define region / group;
rbreak after / summarize;
title 'Using style popup tagset template';
run;
ods markup close;
[/pre]

The style_popup tagset template uses JavaScript to change the color of the page element when you hover your mouse over it and when you double click after the cell turns salmon-orange, then a popup window appears with all the style information relevant to that table cell. That tagset template and custom CSS file were written by the developers as a diagnostic tool to help users figure out what style attributes were used in an ODS HTML table cells. But the coding/application of the different technologies (HTML, JavaScript, CSS) all happens within ODS. (when you use the simple STYLESHEET= option, SAS/ODS is MAKING a CSS file; when you use the STYLESHEET=(URL=...) option, SAS/ODS will use an EXISTING CSS file.)

That example may be overkill for what you want to do, but it shows the breadth of what is possible in Base SAS.

Also, if you go down the SP road, there are only certain client apps that can "receive" HTML from an SP. EG is one of them -- but WRS is not. So if you built your SP to gen some custom HTML, you'd be limiting where the SP could run. (...which might be OK for your purposes...)

cynthia
DonH
Lapis Lazuli | Level 10
Thanks Cynthia. Exactly the pointers I needed.

I had forgotten about the flyover attribute. It might meet the user's/client's needs. I thought I needed to do something more because the pop-up text could be long. Based on a quick check I ran using a modfied version of your example, the generated pop-up does wrap the text and can even extend beyond the results window and even the EG window.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 918 views
  • 0 likes
  • 2 in conversation