How to create EMF graph output files that can be edited outside of your SAS® program

This post was kindly contributed by SAS Users - go there to comment and to read the full post.

What happens if you need to edit graph output files from SAS in a different application (for example, Microsoft Word)? It is not recommended that you edit your SAS graph output outside of SAS, but if you must do so, this article discusses the graphics output options that you need to use.

Understanding the EMF graph output types

To create graphics output that is editable, you need to create your graphics output as EMF (Enhanced Metafile Format) graph output. The EMF graph format is a vector-based graphics format. Formats such as PNG, GIF, JPEG, and TIFF are bitmap image formats and, typically, bitmap image formats cannot be edited.

You can either create a stand-alone EMF graph output file or embed your EMF graph output inside an RTF document by using the ODS RTF destination. The EMF graph format is the default graph format when you want to create graphics output with the ODS RTF destination.

By design, the default EMF graph output that SAS creates is in an EMF Plus (EMF+) format. However, this type of EMF graph output is not editable. To create an EMF graph output that you can edit, you must create your EMF graphics output in a format known as EMF Dual format. This format combines EMF Plus output and traditional EMF graph output in a single graph file.

Creating EMF Dual graph output with the SAS/GRAPH® procedures

If you are using a SAS/GRAPH procedure (such as GPLOT or GCHART), you can create EMF Dual graph output by specifying the DEVICE=EMFDUAL option in the GOPTIONS statement:

goptions device=emfdual;

When you use the EMFDUAL device driver to write a stand-alone EMF graph file to disk, use code similar to the following:

ods _all_ close; 
ods listing; 
filename grafout "\file-path\file-name.emf"; 
goptions device=emfdual gsfname=grafout;
/* Your SAS/GRAPH procedure code goes here */

When you use the EMFDUAL device driver to write an RTF document to disk, use code similar to the following:

goptions device=emfdual;
ods _all_ close; 
ods rtf file="\file-path\file-name.rtf"; 
/* Your SAS/GRAPH procedure code goes here */
ods rtf close; 
ods listing;

Creating EMF Dual graph output with ODS Graphics and the SAS SG procedures

If you are using ODS Graphics or the SAS statistical graphics (SG) procedures (such as SGPLOT), you can create EMF Dual graph output by adding the following REGISTRY procedure code to the top of your existing code:

%let workdir=%trim(%sysfunc(pathname(work)));
data _null_;
   file "&workdir./emf94.sasxreg";
   put '[CORE\PRINTING\PRINTERS\EMF\ADVANCED]';
   put '"Description"="Enhanced Metafile Format"';
   put '"Metafile Type"="DUAL"';
run;
proc registry import="&workdir./emf94.sasxreg";
run;

Then, specify the OUTPUTFMT=EMF option in the ODS GRAPHICS statement before the procedure step. Here is an example:

ods graphics / outputfmt=emf;

Understanding issues that might occur

The EMF format does not support data skins or transparency. Therefore, if your SAS code creates graphics output using data skins or transparency, keep in mind that the graph output is created as an image and the following note is written to the log:

NOTE: The graph in the RTF destination will be rendered as an image due to the use of transparency and data skin.

To create editable vector-based graphics output, you need to modify your code to not use data skins or transparency.

Also, graphs that use dashed lines cannot be edited outside of SAS. In this case, you need to modify your SAS code or the ODS style so that the graph is created with solid lines instead of dashed lines.

Conclusion

Instead of editing a graph outside of SAS, it is recommended that you modify your graph by using statements and options in the SAS code itself. If you need assistance about how to do that, contact SAS Technical Support.

See also:

How to create EMF graph output files that can be edited outside of your SAS® program was published on SAS Users.

This post was kindly contributed by SAS Users - go there to comment and to read the full post.