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

Hi,

I would like to save my PROC GPLOT graph in a specific folder using the filename statement but it keeps saving it to a temporary folder. Does anyone know how to debug this?

Thanks!

code:

filename grafout "H:\My Document\picture.jpeg";

goptions reset=all gsfname=grafout gsfmode=replace device=jpeg;

proc gplot data = KM_Weibull_var_0;

    plot survival*t2dss = grade_new ;

run;

quit;

filename grafout clear;

Log message shows:

NOTE:  records written to C:\Temp\SAS Temporary Files\_TD5676_PC004231_\gplot7.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
MikeZdeb
Rhodochrosite | Level 12

Hi.  The behavior you describe relies on the RESULTS setting you have specified under the tab TOOLS/OPTIONS/PREFERENCES (see attached).  This adds a GPATH= option to the ODS HTML statement that it generates, and that's what directs your output to the temp folder.

 

If  you have selected just HTML, you get the behavior you described.  If you have selected LISTING (as I have) you'll get ...

 

52 filename graphout 'z:\test.png';
53
54 goptions reset=all device=png gsfname=graphout;
55
56 proc gplot data=sashelp.class;
57 plot height*weight;
58 run;

NOTE: 9532 bytes written to z:\test.png.
59 quit;

 

If you have both HTML and LISTING checked, you get ...

 

61 filename graphout 'z:\test.png';
62
63 goptions reset=all device=png gsfname=graphout;
64
65 proc gplot data=sashelp.class;
66 plot height*weight;
67 run;

NOTE: Writing HTML Body file: sashtml1.htm
NOTE: 9520 bytes written to C:\Users\Mike\AppData\Local\Temp\SAS Temporary Files\_TD1112_MIKENEW_\gplot6.png.
NOTE: 9532 bytes written to z:\test.png.
68 quit;

 

 

 


tools-options-preferences-results.jpg

 

If you don't want to specify ODS LISTING, you can redirect the ODS HTML that SAS generates by adding:

 

 ods html gpath="<your path>";

 

Before your PROC GPLOT statement.

View solution in original post

7 REPLIES 7
Reeza
Super User

Try using the jpg file extension rather than JPEG.

There's a note in the docs regarding this:

SAS/GRAPH(R) 9.2: Reference, Second Edition

If you specify the filename in the FILENAME statement, you must include the proper file extension. See About File Extensions.

filename grafout "H:\My Document\picture.jpg";

goptions reset=all gsfname=grafout gsfmode=replace device=jpeg;

proc gplot data = KM_Weibull_var_0;

    plot survival*t2dss = grade_new ;

run;

quit;

filename grafout clear;

alai7
Calcite | Level 5

Thanks Reeza. I changed my filename to ".jpg" but it's still saving it to my temporary folder.

Do you have any other ideas why it's doing this?

Also, i'm using SAS 9.3. Does the version matter?

thanks

Reeza
Super User

Works for me on SAS 9.3.

If you don't have any errors in the log I'd contact tech support.

1    filename grafout "C:\temp\picture_sample.jpg";

2    goptions reset=all gsfname=grafout gsfmode=replace device=jpeg;

3    proc gplot data = sashelp.class;

4        plot weight*height = sex ;

5    run;

NOTE:  records written to C:\temp\picture_sample.jpg

6    quit;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: PROCEDURE GPLOT used (Total process time):

      real time           1.92 seconds

      cpu time            0.34 seconds

7    filename grafout clear;

NOTE: Fileref GRAFOUT has been deassigned.

RyanSimmons
Pyrite | Level 9

I am having the same problem. Using this code:

 

filename graphout "C:\tmp\loadingplot.png";

goptions reset=all device=png gsfname=graphout;

axis1 label=(angle=90 "Factor 2 Loading") order=(-0.5 to 1 by 0.5) minor=none;

axis2 label=("Factor 1 Loading") order=(-0.5 to 1 by 0.5) minor=none;

PROC GPLOT data=_factors;

plot Factor2*Factor1=1 / vaxis=axis1 haxis=axis2;

format Factor1 z4.2;

format Factor2 z4.2;

run;

quit;

 

No matter what path I put into the filename (and I have checked to make sure the paths are valid), it writes the file to a folder in the SAS Temporary Files directory, without even assigning it the right name.

 

Does anybody have any idea what is going on? This behavior only manifests itself when using goptions. Saving files using ODS works perfectly fine. For example, this code saves the file with the right name in the correct directory:

 

ods graphics / reset=index imagename='scatter_example' imagefmt=png;

ods listing gpath="C:\tmp";

PROC SGPLOT data=test;

scatter x=covariate y=response / markerattrs=(symbol=CircleFilled);

run;

ods graphics off;

ods listing close;

 

So why does this happen with the goptions output? Even setting the SAS temporary directory to the one I want and then running the code doesn't change where SAS decides to write/name the file.

RyanSimmons
Pyrite | Level 9

Well, moments after posting, I discovered the solution. Still not sure as to the source of the problem, but simply adding

 

ods listing;

 

Before the code works. Of course, it isn't clear to me why exactly this behavior is happening. Further, it still creates the problem where now SAS is actually outputting TWO image files:

 

3863 run;

NOTE: 30124 bytes written to C:\tmp\gplot31.png.

NOTE: 30134 bytes written to C:\tmp\loadingplot.png.

3864 quit;

 

 

MikeZdeb
Rhodochrosite | Level 12

Hi.  The behavior you describe relies on the RESULTS setting you have specified under the tab TOOLS/OPTIONS/PREFERENCES (see attached).  This adds a GPATH= option to the ODS HTML statement that it generates, and that's what directs your output to the temp folder.

 

If  you have selected just HTML, you get the behavior you described.  If you have selected LISTING (as I have) you'll get ...

 

52 filename graphout 'z:\test.png';
53
54 goptions reset=all device=png gsfname=graphout;
55
56 proc gplot data=sashelp.class;
57 plot height*weight;
58 run;

NOTE: 9532 bytes written to z:\test.png.
59 quit;

 

If you have both HTML and LISTING checked, you get ...

 

61 filename graphout 'z:\test.png';
62
63 goptions reset=all device=png gsfname=graphout;
64
65 proc gplot data=sashelp.class;
66 plot height*weight;
67 run;

NOTE: Writing HTML Body file: sashtml1.htm
NOTE: 9520 bytes written to C:\Users\Mike\AppData\Local\Temp\SAS Temporary Files\_TD1112_MIKENEW_\gplot6.png.
NOTE: 9532 bytes written to z:\test.png.
68 quit;

 

 

 


tools-options-preferences-results.jpg

 

If you don't want to specify ODS LISTING, you can redirect the ODS HTML that SAS generates by adding:

 

 ods html gpath="<your path>";

 

Before your PROC GPLOT statement.

GraphGuy
Meteorite | Level 14

You might want to try the following more modern syntax instead.

Ods html will create an extra html file that you don't really need (if you just want the graphic file), but you can just ignore or delete it.

 

I would also highly recommend using png rather than jpeg. Jpeg is better suited for things like photographs, but png will probably create a sharper looking graph.

 

filename odsout 'c:\graph_test\';
ODS LISTING CLOSE;
goptions device=png;
/* or device=jpeg */
ODS HTML path=odsout body="junk.htm";
proc gplot data=sashelp.class;
plot height*weight / name='picture';
run;
quit;
ODS HTML CLOSE;
ODS LISTING;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 7 replies
  • 27058 views
  • 8 likes
  • 5 in conversation