BookmarkSubscribeRSS Feed
Dorota_Jarosz
Obsidian | Level 7
My OS is Windows Vista and I am using SAS 9.2 TS2M3. I have problems with renaming the graphs made with proc gplot when I try to redirect output to a path different than the default. The renaming does not work at all. I am only getting gplot.png, gplot1.png, gplot2.png, etc. The html document gets a proper assigned name though.

Even with the default path, the following statements do not place the image in the subdirectory \image, but in the main path and I have to move them manually in order for the html document to work. I am getting src="images\Myplot.gif" in the html body document, but the image file is in the parent directory (actually my Desktop).

OK, I know I can forget the gpath='.' (url="images/") and simply use gpath='.' but this is the only combination that works.

If I redirect the graphics output I get the entire path embedded in the html document, so it is not easily portable and all the graphs get default names.
I really need to use my external drive for all temporary SAS files.

Any suggestions, please?

P.S. I just checked the (url=none) option and it helped with no path embedded in the redirected html document, just src="gplot8.png" but the images are still only gplot.png, gplot1.png etc. and reset=index does not work either here. How to get them renamed? I produce many graphs with just one run of the program. Identifying them is a real pain. This is for proc gplot output. Proc sgplot seems to work.

Message was edited by: Dorota_Jarosz Message was edited by: Dorota_Jarosz
4 REPLIES 4
DanH_sas
SAS Super FREQ
As a rule, PATH= and GPATH= tell ODS where you PHYSICALLY want the output. The (URL=) specifies the path to generate in the SRC= of the HTML file. Therefore, to generate your output in an image subdirectory AND have your relative image path in the SRC=, do this:

ods html gpath='image' (url="images/")

Let me know if that works for you.

Thanks!
Dan
Dorota_Jarosz
Obsidian | Level 7
Thank you so much, Dan, for responding to my post in such a timely manner. I just tested the gpath="images" (url="images/") and it works! I got a plot in subdirectory \images of the path and the html document references the image correctly: src="images/gplot.png." So portability of html is solved. Thanks!

As you can see though the renaming does not work. My ods graphics statement contains reset=index and imagename="Myplot" but the image is named gplot the first time around I run the code, gplot1, gplot2, etc. on consecutive run, regardless whether I delete the previous version or not. The html document gets replaced.

So, I still have a major problem with reset=index and imagename= options.

Another issue: I often would be happy without the html document altogether. Is there a way to create just a png image that I can import into my paper? When I suppress the ods html statement, I get an error that no output is open.
Dorota_Jarosz
Obsidian | Level 7
I found the answer for renaming the graphs. For regular gplot procedure (as opposed to sgplot) I have to control the output with the goptions and filename statements - the old fashion way.
goptions gsfname=mypng1;
where mypng1 is the file reference defined with the filename statement.
filename mypng1 "E:\MyProject\SAS_output\images\Myplot.png";

It would be REALLY helpful if the SAS 9.2 documentation mentioned or even emphasized these differences. In particular that imagename=filename option of the "ods graphics on;" statement does not affect the output of the gplot.

To stop SAS from adding consecutive numerals to subsequent graphs, use:
goptions gsfmode=replace;
together with the gsfname=mypng1;.

Message was edited by: Dorota_Jarosz
DanH_sas
SAS Super FREQ
For GRSEG-based graphics like GCHART and GPLOT, the ODS GRAPHICS statement will not work for you. To override the name of the image, use the NAME= option on the procedures. To reset the index, just delete the entries from the WORK.GSEG catalog.

Hope this helps,
Dan

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 4 replies
  • 4679 views
  • 0 likes
  • 2 in conversation