BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marta25
Obsidian | Level 7

I am switching from SAS Studio to SAS On demand and I am having some trouble.

In particular, when I create a plot and I want to have as an output a .png file, where and how should I save it?

 

I am trying with this code before the PROC SGPLOT procedure:

ods html path='/home/u48749812/my_data/Plots' style=my_style image_dpi=500;
ods listing gpath='/home/u48749812/my_data/Plots';
ods graphics on /attrpriority=none imagename="image01" imagefmt=png noborder;

proc sgplot...

In this way an empty file is saved on the SAS server (in my folder Plots), which can't be open.

 

What am I doing wrong? 

And is there a way to directly save the image somewhere on my local computer, or should I always save it on the SAS server and download it manually?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Run this:

ods html path='/home/...../plots'(url=NONE) style=my_style image_dpi=500;
ods graphics on /attrpriority=none imagename="image01" imagefmt=png noborder;

proc sgplot data=sashelp.class;
vbar sex;
run;

ods graphics off;
ods html close;

Then download both the .htm and the .png file to the same directory, and double-click the .htm.

The URL=NONE option makes the reference in the HTML code relative; otherwise you'd have the full path in there, which (most likely) does not exist in your local computer.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Run this:

ods html path='/home/...../plots'(url=NONE) style=my_style image_dpi=500;
ods graphics on /attrpriority=none imagename="image01" imagefmt=png noborder;

proc sgplot data=sashelp.class;
vbar sex;
run;

ods graphics off;
ods html close;

Then download both the .htm and the .png file to the same directory, and double-click the .htm.

The URL=NONE option makes the reference in the HTML code relative; otherwise you'd have the full path in there, which (most likely) does not exist in your local computer.

marta25
Obsidian | Level 7

Thanks, but it still results in the same problem. If I double click on the htm file, an empty window on the browser is open. And the png file is empty.

I would simply like to save my figure as a png file, it was so easy to do that before...

And I do not need the htm file, is it really necessary to generate one?

Kurt_Bremser
Super User

First of all, you can download the png file alone to view it. The HTML is just "wrapped around" by using ODS HTML.

The code I posted (very simple) created a combination which opened well on my Mac after downloading both.

It is essential that you run ALL of the code (including ODS HTML CLOSE) before downloading the files.

Inspect the files before and after download to see the sizes.

 

If in any doubt, post the complete log of your code, starting with ODS HTML and ending with ODS HTML CLOSE.

marta25
Obsidian | Level 7

Thank you. Actually I could make it work avoiding ods html and using only ods listings and ods graphics, in this way:

ods listing gpath ='/home/.../plots' style=styles.new_font;
ods graphics / attrpriority=none imagename="image01" imagefmt=png noborder;

In this way the png file is saved and I can open it normally...

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 3475 views
  • 5 likes
  • 2 in conversation