BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

The Save picture as ... menu item works file to make a file from the image in the internal HTML viewer of SAS Display Manager in SAS 9.4m7.

 

Why not just use that?

 

If you want to remove the descriptions from the file that is also not hard as was already shown before.  If you use the EMBED option and what to find the name of the file it created you can scrape it from the HTML file.

46   data _null_;
47     infile html;
48     input;
49     if index(_infile_,'embed');
50     put _infile_;
51   run;

NOTE: The infile HTML is:
      Filename=c:\downloads\svg_test.html,
      RECFM=V,LRECL=32767,File Size (bytes)=36259,
      Last Modified=10Aug2024:14:10:42,
      Create Time=10Aug2024:14:10:37

<embed src="WilcoxonBoxPlot3.svg" type="image/svg+xml"/>

You can then make a copy of that file without the description tags.

data _null_;
  infile "c:\downloads\WilcoxonBoxPlot3.svg" ;
  file "c:\downloads\WilcoxonBoxPlot_fixed.svg" ;
  input;
  if _infile_=:'<des' then delete;
  put _infile_;
run;
Tom
Super User Tom
Super User

As suggested before you could just add code to remove the description tags from the file.

 

For example using your example report:

%let path=c:\downloads;

ods html close;
ods html5 path="&path"(url=none) file="svg_test.html" ;
proc npar1way data=sashelp.cars wilcoxon;
class origin;
var weight;
run;
ods html5 close;

filename html "&path/svg_test.html";
filename copy temp;

data _null_;
  infile html ;
  file copy;
  input;
  if _infile_=:'<des' then delete;
  put _infile_;
run;

data _null_;
  infile copy ;
  file html;
  input;
  put _infile_;
run;
spirto
Quartz | Level 8

@Tom Ah yes you are correct! Thank you for highlighting this. When I use the Save picture as... option it saves the SVG without the pop-op text.

 

What is perplexing me is that when I try to copy the SVG (from the Results Viewer), and paste it to a word document, it also copies over that pop-up text. 

 

perplexed.png

 

DanH_sas
SAS Super FREQ

I think the following is happening:

 

First, the pop-up description text is not coming from the SVG output, per se -- it's coming from a javascript function in the HTML file that reads the description from the SVG output and displays it. When you "save the picture" from the results viewer, you are getting only the SVG output without the javascript functions. However, when you "copy" the inline SVG output, you are probably getting the entire HTML output, including the functions.

 

I addition to getting the individual SVG files by using embedding, you can also get them by just generating ODS LISTING output and setting OUTPUTFMT=SVG on the ODS GRAPHICS statement.

spirto
Quartz | Level 8

@DanH_sas Thanks for the Javascript clue! That led me to determine the root cause of the behavior.

 

Turns out the pop-up text is driven by two embedded Javascript addEventListener methods (within the SVG code itself) that create and hide the tooltip. Here are the methods below. You can see there is one when you move the mouse into the SVG ('mousemove') and one when you 'mouseout' of the SVG. In return these two methods execute the ShowTooltip and HideTooltip functions when the respective events occur. 

 

SVG_IDX2_SVGRoot.addEventListener('mousemove', SVG_IDX2_ShowTooltip, false);
SVG_IDX2_SVGRoot.addEventListener('mouseout', SVG_IDX2_HideTooltip, false);

To prevent the tooltip from showing up when right clicking to copying the image all one needs to do is add a single line of code to add an additional listener method that listens for the 'contextmenu' event. When you right click to bring up the contextmenu, the method will execute the HideTooltip function and Voilà the pop up disappears. 

 

SVG_IDX2_SVGRoot.addEventListener('contextmenu', SVG_IDX2_HideTooltip, false);

Doing everything this way allows you to have your cake (display the pop-up) and eat it (temporarily hide it when copying) too.

 

@Rick_SAS  @DanH_sas - Curious if this is something we can pass along to the SAS ODS developers. They may be interested in making a HotFix. I have no idea how to contact SAS and make this suggestion. 

 

Lastly thank you to all who took this journey with us. Definitely a rabbit hole!

 

Rick_SAS
SAS Super FREQ

> I have no idea how to contact SAS and make this suggestion. 

To report a suspected bug, contact SAS Technical Support and open a case with them: SAS Technical Support | SAS Support

spirto
Quartz | Level 8

@Rick_SAS Thanks Rick! I reached out to SAS and received a solution.

 

There is an undocumented method of modifying the Tooltip behaviour for SVGs. I requires modifying the SAS registry to turn off tooltips.

 

Two ways to do this:

  1. Via the SAS Display Manager. Open the registry editor (Solutions > Accessories > Registry Editor). From there navigate to CORE\PRINTING\PRINTERS\SVG\ADVANCED, double click Tooltips and change the value to "0".SVGregistry.png
  2. Do this programmatically via the following code
    %let workdir=%trim(%sysfunc(pathname(work)));
    
    data _null_;
       file "&workdir./svg_notip.sasxreg";
       put '[CORE\PRINTING\PRINTERS\SVG\ADVANCED]';
       put '"Tooltips"=int:0';
    run;
    
    proc registry import="&workdir./svg_notip.sasxreg";
    run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 21 replies
  • 5745 views
  • 0 likes
  • 7 in conversation