Normally SAS works with graphs in a proprietary format nothing else can use. However, it can save files in a variety of standard formats. If you want to do anything more than look at the graphs on the screen, putting the graph in one of these other formats is probably essential.
This article will focus on three formats: PDF (Portable Document Format), PostScript, and PNG (Portable Network Graphic). Each has its uses, and which one you should use depends on what you want to do with the graph. The following chart lists some recommendation. Note that these are only recommendations based on what tools most of our users have and are familiar with. For example, if you have Ghostview installed on your PC, you can easily use it to print PostScript files.
|What you want to do with the graph...||The format you should use...|
|Print it from Linux||PostScript|
|Print it from Windows|
|Share it with colleagues via email or the web|
|Put it in a Web page||PNG|
|Put it in a Word document||PostScript|
|Edit it with an image editor*||PNG|
What fonts SAS makes available depends on the format you use. If you choose PNG, SAS can only use one default font. If you choose PDF, SAS allows you to choose from the following:
With PostScript you have all these and more. See Getting More Information for instructions on getting a complete list.
Note that you can only choose one font for all the text in the graph.
Once you have chosen a format and a font, it's time to put the code in your program that tells SAS to use them. Put the following before the proc step that creates the graph:
filename output "file";
goptions reset=all device=format gsfname=output gsfmode=replace ftext="font";
Replace file with the name you want to give the file. Give it an extension that matches the file type you want: .pdf for PDF, .ps for PostScript, or .png for PNG. This is especially important if you want to use the file on a PC, as Windows will use the extension to decide what kind of file it is.
Replace format with the name of the format you want. The names are pdf for black and white PDF, pdfc for PDF files including color, ps for PostScript, and png for PNG.
Replace font with the name of the font you want. Copy the name exactly from the list above. If you are using PNG, it doesn't matter what font you choose, you'll always get the same one. However, a font name must be there and must not have any spaces.
If you want to create a second graph with the same options, put a second filename line right before the proc that creates the second graph, with a different file. If the second graph should have a different format or font, include a second goptions line as well.
Running the Program
Once these lines are inserted, your program can be run normally with one exception. For whatever reason if you choose to create a PNG file, SAS will briefly open an interactive session even if you run the program in batch mode. Thus you will need to be able to display Linux graphics. On a PC this means X-Win32 must be running. See Connecting to SSCC Linux Computers using X-Win32 for more information. What's more, SAS will fail to create a window if there is no other graphical application running. So start something like xclock before running SAS if you're planning to make a PNG file.
Inserting a PostScript File Into Word
If you create a PostScript file you can easily insert it into a Word document. Start Word and open the document. Then click Insert, Picture, From File. Go to the directory where you saved the PostScript file, set Files of Type: to All Files (*.*), and double click on the file you want. Word will then ask what it should convert the file from. Choose Encapsulated PostScript, click Okay, and the graph will appear in your document.
You can get a full list of available formats (SAS refers to them as devices) by running the following program:
proc gdevice catalog=sashelp.devices nofs;
You can then get more information about a particular format, including what fonts SAS can use in that format, by running:
proc gdevice c=sashelp.devices nofs;
Just replace format with the format you want (ps for example).
Last Revised: 3/20/2007