BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

I can't get graphics to appear in the output file in SAS Viya with a relatively simple ODS HTML statement. This works fine in SAS 9.4, but doesn't work the same in SAS Viya.

 

ods html file='print.html' path="&_userhome" gpath="&_userhome";

proc print data=sashelp.class;
run;

proc sgplot data=sashelp.class;
scatter x=height y=weight;
run;

ods html close;

 

The output folder &_userhome exists. The output HTML file shows PROC PRINT output but not PROC SGPLOT output. How to fix?

 

PaigeMiller_0-1743616149075.png

 

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Solution provided by SAS

 

ods html5 file="&_userhome./print2.html" options (bitmap_mode='inline'); 
proc print data=sashelp.class; 
run; 

proc sgplot data sashelp.class; 
scatter x-height y=weight; 
run; 
ods html5 close; 
--
Paige Miller

View solution in original post

7 REPLIES 7
SASJedi
Ammonite | Level 13

What version of SAS Viya are you using? I ran this code in Viya 2025.01

ods html file='print.html' path="&_userhome" gpath="&_userhome";
proc print data=sashelp.class(obs=5);
run;
proc sgplot data=sashelp.class;
scatter x=height y=weight;
run;
ods html close;

and got the expected result:

SASJedi_0-1743620335271.png

The code also produced the expected results in Viya for Learners (LTS 2024.09). 

 

 

Check out my Jedi SAS Tricks for SAS Users
PaigeMiller
Diamond | Level 26

No, that's not what I am asking about. You are looking at the results tab in Viya, whereas I am looking at the results in the output file named print.html opened in my web browser. In the results tab, I see the plot like you do, but it is not there in the print.html file.

--
Paige Miller
SASJedi
Ammonite | Level 13

Ah. OK. If you download the files and review the HTML, you can see that SAS hard-coded the path in the src=specification for the image.  It does the same in Windows SAS. Try moving both files to a new location in Windows and you'll see the same effect. To work around this, you'd have to edit the HTML page to change the hardcoded path to this:
src="./SGPlot1.png" 

 

Then, as long as you place both the HTML file and the .png file in the same folder, it will work as expected. 

 

Check out my Jedi SAS Tricks for SAS Users
PaigeMiller
Diamond | Level 26

It sounds as if you are saying there is no way to write an ODS HTML command and have this work.

 

If that's true, this is very disappointing. In all my years of working in Base SAS, I have found it very helpful to write output including graphics to a particular folder with a specific file name, and keep everything together that way, all done via SAS code. If that isn't possible in Viya, this is a major hit to my normal workflow.

 

I await to hear from others if this is possible.

--
Paige Miller
Ksharp
Super User
%let _userhome=c:\temp\z ;

ods html body='print.html' path="&_userhome" gpath="&_userhome";

proc print data=sashelp.class;
run;

proc sgplot data=sashelp.class;
scatter x=height y=weight;
run;

ods html close;

Also try HTML5 instead of HTML :

ods html5 body='print.html' path="&_userhome" gpath="&_userhome";
............
ods html5 close;

PaigeMiller
Diamond | Level 26

Thanks @Ksharp , but neither of these produce the desired plot in print.html using my SAS Viya.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Solution provided by SAS

 

ods html5 file="&_userhome./print2.html" options (bitmap_mode='inline'); 
proc print data=sashelp.class; 
run; 

proc sgplot data sashelp.class; 
scatter x-height y=weight; 
run; 
ods html5 close; 
--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Discussion stats
  • 7 replies
  • 1944 views
  • 4 likes
  • 3 in conversation