BookmarkSubscribeRSS Feed
Junyong
Pyrite | Level 9

I just found that PROC GPLOT with GOPTION FTEXT doesn't work when GSFNAME is added. Here's the simple sample code.

resetline;
option nodate nonumber ls=128 ps=max;
goption xpixels=640 ypixels=480 border ftext="Cambria" htext=11pt;

/*------------------------------------------------------------------------------------
1. This is the dataset to plot.
------------------------------------------------------------------------------------*/
data _01;
do X=0 to 10;
Y=X**2;
output;
end;
run;

/*------------------------------------------------------------------------------------
2. This GPLOT works correctly with the Cambria font.
------------------------------------------------------------------------------------*/
symbol i=join;
proc gplot data=_01;
plot Y*X;
run;

/*------------------------------------------------------------------------------------
3. However, the GPLOT below doesn't work and substitutes the font with something else.
------------------------------------------------------------------------------------*/
filename SQUARE "Desktop\Square.png";
goption gsfname=SQUARE device=png gsfmode=replace;
proc gplot data=_01;
plot Y*X;
run;

quit;

As described above, GOPTION FTEXT works without GSFNAME, but doesn't work with GSFNAME. Hope there exists a proper solution. Here're the outcomes from both PROC GPLOTs with and without the Cambria font.

1.png2.png

4 REPLIES 4
GraphGuy
Meteorite | Level 14

Although you can still use the gsfname technique, I haven't used it since I was using SAS v6.x back in grad school in the 1990s, and therefore I'm not sure of the exact answer to your gsfname question.

 

But in the more recent versions of SAS, I almost always use "ods html" with device=png. Here would be some alternate code to produce a png image of your GPlot graph. You can set the odsout to whatever directory you want your output written to (I usually run my SAS jobs in batch, and set it to the current directory (which is '.').

 

%let name=square;
/*
filename odsout 'Desktop';
*/
filename odsout '.';

goptions device=png;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;

goption xpixels=640 ypixels=480 border ftext="Cambria" htext=11pt;

data _01;
do X=0 to 10;
Y=X**2;
output;
end;
run;

symbol1 value=none interpol=join color=blue;
title1 ls=1.5 h=14pt "GPlot with ftext='Cambria'";
proc gplot data=_01;
plot Y*X / name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

 

square.png

Junyong
Pyrite | Level 9

Thanks for your kind details. Here's the result of my trial.

1. I just copied and pasted all your code, but it produced the same problem. Here're the outcomes—SAS used one random truetype font and didn't apply Cambria.

1.png2.png

2. I didn't mention in the OP, but I mostly use the following code as the header to deactivate the HTML environment as it's slower. My apologies for your confusion.

resetline;
ods html close;
ods graphics off;
ods listing;

3. In my working example, I used PNG to output, but I'm currently working with EMF to produce a vector image. Unfortunately, it seems the HTML environment doesn't support EMF and only deals with a bitmap image.

3.png

Again, I much appreciate your time.

ballardw
Super User

While I strongly support @GraphGuy suggestion to shift to SGPLOT and the SG procedures you can try

 

filename SQUARE "x:\data\Square.png";
goption gsfname=SQUARE device=png gsfmode=replace;
ODS USEGOPT ;
proc gplot data=_01;
plot Y*X;
run;

quit;

The ODS USEGOPT statement tells ODS output to use traditional SAS/Graph options. You didn't specify an ODS destination so I assume that HTML is effect. You likely should turn this option off when not needed using ODS NOUSEGOPT. This note from the documentation on FTEXT applies:

 

Note: When you use ODS to send graphics to an HTML destination, and titles and footnotes are rendered as part of the HTML body file instead of the graphic image, you must specify the ODS USEGOPT statement for this option to work.

GraphGuy
Meteorite | Level 14

Just to clarify, I didn't suggest to switching to SGplot in my comment. 🙂

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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