Usage Note 49421: A "Cannot write image" error might occur with ODS Graphics and the SAS/GRAPH® Statistical Graphics (SG) procedures
The following error message might be written to the SAS® log when producing graphics output with either ODS Graphics or any of the SAS/GRAPH Statistical Graphics (SG) procedures such as SGPLOT:
ERROR: Cannot write image to filename.png. Please ensure
that proper disk permissions are set.
NOTE: The SAS System stopped processing this step because of errors.
The error occurs when SAS attempts to write one or more graphics files to a directory that SAS cannot write to. This error occurs when SAS attempts to write to a directory that SAS does not have authorization to update.
The error above commonly occurs when you are writing your graphics output to a specific ODS destination (such as ODS HTML or ODS PDF) but at the same time, the listing destination is also open. In this case, you can circumvent the problem by adding the following statement to the top of your code (before the other ODS statements in your code):
ods listing close;
If you want to write your graphics output to the listing destination, another way to circumvent this problem is to add the ODS LISTING statement to your code before your SAS procedure step. Use the GPATH= option in the ODS LISTING statement to specify an existing directory to which SAS has Update access. For example, if you are running on Microsoft Windows and you want SAS to write its graphics output to the TEMP folder on your C: drive, add the following statement to your code before your SAS procedure step:
ods listing gpath="c:\temp";
Note that the GPATH= option in the ODS LISTING statement is honored only when using ODS Graphics or the SAS/GRAPH SG procedures. It is not honored when using regular SAS/GRAPH procedures such as GCHART and GPLOT.
Another option is to wrap ODS HTML statements around your existing SAS procedure code. Use the PATH= option in the ODS HTML statement to specify the directory to which SAS writes the output. The following sample code tells SAS to write all of its HTML and graph output to the TEMP folder on your C: drive:
ods _all_ close;
ods html path='c:\temp' (url=none) file='sastest.html';
/* Your SAS procedure code goes here */
ods _all_ close;
Operating System and Release Information
Microsoft® Windows® for 64-Bit Itanium-based Systems
Microsoft Windows Server 2003 Datacenter 64-bit Edition
Microsoft Windows Server 2003 Enterprise 64-bit Edition
Microsoft Windows XP 64-bit Edition
Microsoft® Windows® for x64
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows XP Professional
Windows Vista for x64
64-bit Enabled AIX
64-bit Enabled HP-UX
64-bit Enabled Solaris
Linux for x64
OpenVMS on HP Integrity
Solaris for x64
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
A "Cannot write image" error might occur with ODS Graphics and the SAS/GRAPH Statistical Graphics (SG) procedures.