<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988163#M25910</link>
    <description>&lt;P&gt;Did you used:&lt;/P&gt;
&lt;PRE&gt;ods listing gpath='c:\temp';&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sgf/2015/11/20/how-to-increase-the-resolution-of-your-sas-graphics-output/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2015/11/20/how-to-increase-the-resolution-of-your-sas-graphics-output/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2017/06/08/getting-started-output-formats/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2017/06/08/getting-started-output-formats/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;SPAN&gt;SAS_EXECFILEPATH macro variable is not working in batch mode (I tested), you need to set parameter&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;-set SAS_EXECFILEPATH "c:\temp\"&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;in batch process file.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 16 May 2026 07:06:49 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-05-16T07:06:49Z</dc:date>
    <item>
      <title>A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GPATH</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988129#M25908</link>
      <description>&lt;P&gt;I got tired of receiving error messages from SAS telling me that a particular folder was not authorized to receive output, as in&lt;/P&gt;
&lt;P&gt;"WARNING: GPATH or PATH is not a writable directory. It will be ignored.&lt;/P&gt;
&lt;DIV class="sasError"&gt;ERROR: Cannot write image to SGprint. Please ensure that proper disk permissions are set.".&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;So I wrote %ODS_GRAPHICS, which is designed to create ODS listing and ODS graphics statements to direct graphics output to a specified file in a specified folder. The complete macro code and test code are included in the attached SAS program file.&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;The macro uses the SAS_EXECFILEPATH macro variable so it must be run either in batch mode (not tested) or interactive mode (requiring the Enhanced Editor).&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;The argument GPATH_FILENAME specifies the mode of operation:&lt;/DIV&gt;
&lt;UL&gt;
&lt;LI class="sasError"&gt;if &amp;amp;GPATH_FILENAME represents a complete Windows pathname, then the graphics output is put into the specified folder.&lt;/LI&gt;
&lt;LI class="sasError"&gt;if &amp;amp;GPATH_FILENAME represents a filename only, then the graphics output is put into the folder containing the SAS program from which the %ODS_GRAPHICS macro was invoked.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;For example, the macro invocation %ODS_GRAPHICS( "C:\Users\Username\Documents\My SAS Files\TestGraphics\TestODSGraphics.jpg" ) will put output into the TestGraphics folder, and %ODS_GRAPHICS( TestGraphics.tiff ) will put output into the folder containing the program in which the %ODS_GRAPHICS macro was invoked. Note that quotation marks around the name of the output file are optional.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kudos to Art Carpenter, who wrote the original macro %ExecPrg , referenced in&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/48199111/get-the-filename-and-filepath-of-the-code-running" target="_blank"&gt;https://stackoverflow.com/questions/48199111/get-the-filename-and-filepath-of-the-code-running&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2026 18:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988129#M25908</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2026-05-15T18:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988161#M25909</link>
      <description>&lt;P&gt;No file was attached.&amp;nbsp; But why not just post the code for the macro in the pop-up window that appears when you push the Insert SAS Code button in the forum editor?&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2026 01:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988161#M25909</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-16T01:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988163#M25910</link>
      <description>&lt;P&gt;Did you used:&lt;/P&gt;
&lt;PRE&gt;ods listing gpath='c:\temp';&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sgf/2015/11/20/how-to-increase-the-resolution-of-your-sas-graphics-output/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2015/11/20/how-to-increase-the-resolution-of-your-sas-graphics-output/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2017/06/08/getting-started-output-formats/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2017/06/08/getting-started-output-formats/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;SPAN&gt;SAS_EXECFILEPATH macro variable is not working in batch mode (I tested), you need to set parameter&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;-set SAS_EXECFILEPATH "c:\temp\"&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;in batch process file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2026 07:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988163#M25910</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-05-16T07:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988167#M25911</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I got tired of receiving error messages from SAS telling me that a particular folder was not authorized to receive output, as in&lt;/P&gt;
&lt;P&gt;"WARNING: GPATH or PATH is not a writable directory. It will be ignored.&lt;/P&gt;
&lt;DIV class="sasError"&gt;ERROR: Cannot write image to SGprint. Please ensure that proper disk permissions are set.".&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;I have never received this error. What am I missing, can't you just direct the output via ODS HTML or ODS LISTING to a writable directory in your original SAS program (which is what I do)?&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 May 2026 11:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988167#M25911</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2026-05-16T11:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988171#M25912</link>
      <description>&lt;P&gt;You get that message when your code produces graphs that need to be embedded/linked in the HTML output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most often is happens when you have not set the GPATH location and it defaults to the current working directory, but that directory is readonly.&amp;nbsp; Most often for SAS sessions launched for use by Enterprise Guide or SAS/Studio since those typically start with the current working directory some place inside the SAS installation directories which normal SAS users cannot write to.&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2026 13:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988171#M25912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-16T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988185#M25913</link>
      <description>&lt;P&gt;I apologize for submitting this posting without adequately checking that the SAS macro code was attached to it. I thought that I had included it as an attachment, but apparently I was mistaken. Here is the macro code and test code. Note that the HTML destination appears not to be supported. I am running SAS 9.4 TS Level 1M8 on X64_WIN+PRO platform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ODS_GRAPHICS( GPATH_FILENAME ) / minoperator ;

   /* purpose: direct SAS graphics output into specified folder/file under ODS control
    *
    * GPATH_FILENAME ::= complete Windows path to folder\filename into which to store ODS graphics image
    *                    filename of ODS graphics image created in interactively submitted program
    *
    * Examples of use:
    *    %ODS_GRAPHICS( 'C:\Users\Username\Documents\My SAS Files\ODS Graphics Output\Plot Y vs X.PNG' ) ; *** store image in explicitly-specified directory
    *
    *    %ODS_GRAPHICS( 'Plot Y vs X.jpg' ) ; *** store image in directory in which %ODS_GRAPHICS macro is invoked
    *
    * NOTA BENE: this code works only for SAS running in 1) batch mode or in 2) interactive mode using the Enhanced Editor
    *
    * reference: https://stackoverflow.com/questions/48199111/get-the-filename-and-filepath-of-the-code-running
    *            Art Carpenter created the macro %ExecPrg which has been adapted for use in this macro
    */

   /* fetch complete Windows folder pathname, replace macro name ODS_GRAPHICS with user-specified filename that will contain ODS graphics output */

   %if %sysfunc( getoption( sysin )) ne %str() /* determine mode of operation: batch | interactive */
   %then %do ;
      %let PATHNAME = %sysfunc( getoption( sysin )) ; /* batch execution */
   %end ;
   %else %do ;
      %let PATHNAME = %sysget( SAS_EXECFILEPATH ) ; /* interactive execution */
   %end ;

   %if ^%index( &amp;amp;GPATH_FILENAME, \ ) /* not a Windows path, just filename for ODS graphics output in current working directory */
   %then %do ;
      %let REV_STRING     = %sysfunc( reverse( &amp;amp;PATHNAME )) ;
      %let NDX            = %index( &amp;amp;REV_STRING, \ ) ;
      %let GPATH          = %substr( &amp;amp;REV_STRING, &amp;amp;NDX + 1 ) ;
      %let GPATH          = %sysfunc( reverse( &amp;amp;GPATH )) ;
      %let GPATH_FILENAME = &amp;amp;GPATH.\&amp;amp;GPATH_FILENAME ; /* create complete Windows folder path and ODS output file name */
   %end ;
   
   %let STRING     = %sysfunc( dequote( &amp;amp;GPATH_FILENAME )) ; /* remove quotes, if any, from path\filename.imagetype string */
   %let REV_STRING = %sysfunc( reverse( &amp;amp;STRING )) ;
   %let NDX        = %index( &amp;amp;REV_STRING, . ) ; /* find location of '.' for image type */
   %let IMAGETYPE  = %substr( &amp;amp;REV_STRING, 1, &amp;amp;NDX - 1 ) ; /* parse for image type */

   %let REV_STRING = %substr( &amp;amp;REV_STRING, &amp;amp;NDX + 1 ) ; /* exclude image type */
   %let NDX        = %index( &amp;amp;REV_STRING, \ ) ;
   %let IMAGENAME  = %substr( &amp;amp;REV_STRING, 1, &amp;amp;NDX - 1 ) ;

   %let IMAGETYPE = %upcase( %sysfunc( reverse( &amp;amp;IMAGETYPE ))) ;

   %if ^%eval( &amp;amp;IMAGETYPE in BMP DIB EMF EPS EPSI GIF JFIF JPEG JPG PBM PCD PCL PDF PICT PNG PS STATIC SVG TIFF WMF XBM XPM )
   %then %do ;
      %put /-----------------------------------------------------------------\ ;
      %put | ODS destination not one of BMP, DIB, EMF, EPS, EPSI, GIF, JFIF, | ;
      %put |     JPEG, JPG, PBM, PCD, PCL, PDF, PICT, PNG, PS, STATIC, SVG,  | ;
      %put |     TIFF, WMF, XBM, XPM.                                        | ;
      %put | Terminating forthwith.                                          | ;
      %put \-----------------------------------------------------------------/ ;

      %goto EXIT ;
  %end ; 

   /* quote gpath and imagename macro strings */
   %let GPATH     = %substr( &amp;amp;REV_STRING, &amp;amp;NDX + 1 ) ;
   %let GPATH     = %sysfunc( quote( &amp;amp;GPATH )) ;
   %let IMAGENAME = %sysfunc( quote( &amp;amp;IMAGENAME )) ;

   /* assemble ODS statements */
   ods listing gpath=%sysfunc( reverse( &amp;amp;GPATH )) ;
   ods graphics / imagename=%sysfunc( reverse( &amp;amp;IMAGENAME )) imagefmt=&amp;amp;IMAGETYPE ;

%EXIT:

%mend ODS_GRAPHICS ;

/* test complete Windows path/filename, imagefmt=png */

%ODS_GRAPHICS( 'C:\Users\UserName\Documents\My SAS Files\TestGraphics\ods_graphics_test.png' ) ;

proc sgplot data=sashelp.class ; scatter x=height y=weight ; quit ;

proc print data=sashelp.class ; run ;

/* test ODS graphics filename only, imagefmt=tiff */

%ODS_GRAPHICS( filename_only_ods_graphics_test.tiff ) ;

proc sgplot data=sashelp.class ; scatter x=height y=weight ; quit ;

proc print data=sashelp.class ; run ;

/* test ODS graphics filename only, imagefmt=html THIS ODS DESTINATION IS NOT SUPPORTED FOR LISTING OUTPUT */

%ODS_GRAPHICS( filename_only_ods_graphics_test.html )

proc sgplot data=sashelp.class ; scatter x=height y=weight ; quit ;

proc print data=sashelp.class ; run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class="language-sas"&gt;/* note that separate non-macro test code for HTML destination results in error */&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;ods listing gpath='C:\Users\UserName\Documents\My SAS Files\TestGraphics\ods_graphics_test.html';&lt;BR /&gt;1157 ods graphics / imagename="ods_graphics_test" imagefmt=html;&lt;BR /&gt;----&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: BMP, DIB, EMF, EPS, EPSI, GIF, JFIF, JPEG, JPG, PBM, PCD, PCL, PDF,&lt;BR /&gt;PICT, PNG, PS, STATIC, SVG, TIFF, WMF, XBM, XPM.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To those who answered me, thank you for your interest in my work. I have tried to address your comments below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did not test the ODS_GRAPHICS macro code in batch mode because I am using SAS interactively on a PC. I included the batch mode code because Art Carpenter's macro %ExecPrg did so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The folder into which I wrote graphical output did not have write permission so I tried to create code that would eliminate the need for a separate intervention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom (Super User), thank you for your informative comment. Yes, the directory to which default output without a defined GPATH statement is somewhere in the SAS Foundation directory path which is not writeable by default and which I do not want to make writeable so that I don't inadvertently overwrite some file of importance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2026 22:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988185#M25913</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2026-05-16T22:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: A SAS Macro to Use ODS to Direct Graphics Output to a Specified Folder and Avoid the WARNING: GP</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988188#M25914</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You get that message when your code produces graphs that need to be embedded/linked in the HTML output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most often is happens when you have not set the GPATH location and it defaults to the current working directory, but that directory is readonly.&amp;nbsp; Most often for SAS sessions launched for use by Enterprise Guide or SAS/Studio since those typically start with the current working directory some place inside the SAS installation directories which normal SAS users cannot write to.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which is why I never see this error message, I always use GPATH when I create graphics.&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2026 10:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/A-SAS-Macro-to-Use-ODS-to-Direct-Graphics-Output-to-a-Specified/m-p/988188#M25914</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2026-05-17T10:08:17Z</dc:date>
    </item>
  </channel>
</rss>

