If you use SAS® through a graphical interface, you should be able to view and print any high-resolution graphical output through that interface, without the need for special SAS® statements. However, if you use a non-graphical interface or perform batch processing (as from a Linux command line), you may need more control over the destination of your graphical output. This page shows you how to make SAS® save your high-resolution graphical output to a file in PostScript® format (rather than displaying it on the screen or sending it to a default printer). You may then view or print your graph using other resources available on your system.
Suppose you have a SAS® program that
generates a high-resolution graph, and you want that graph
saved in a color PostScript® file named
"myfile.ps" in the current working directory (from which
SAS® was invoked). You can do this by
adding the following lines to your program so that they are executed
before the statement that generates the graph you want to
save:
filename myplot 'myfile.ps';
goptions gsfname=myplot
device=pscolor
gsfmode=replace;
Here, the word "myplot" is not part of SAS®
syntax — you can replace it with any identifier that conforms to the
naming rules. It simply serves as an internal
SAS® label that is associated with the
external file "myfile.ps" by the FILENAME statement. You may create additional
output files with additional FILENAME statements that use other labels. The
graphical output is written to the file associated with whichever label was
most recently specified in a GOPTIONS statement.
The final line forces SAS® to replace (overwrite) any existing file named "myfile.ps" in the current working directory. This may be useful if you run your SAS® program several times with minor modifications, and you want to write the results from the most recent run, but not retain any results from previous runs.
You can also save SAS® graphs to external files in formats other than PostScript®. Consult the official SAS® documentation for details.