| SAS Companion for the Microsoft Windows Environment |
For full details about using SAS/GRAPH software, see
SAS/GRAPH Software: Reference. For further details about using graphics and fonts with the SAS System under Windows, see
Overview of Graphics Considerations.
In most cases, output is
automatically displayed on your monitor when you run a SAS/GRAPH procedure; it is not necessary to specify a SAS/GRAPH device driver. Information about your graphics display is stored in a Windows
information file and is automatically used by the SAS System during an interactive SAS session.
Here is a simple example of how to produce a graphic:
data hat;
do x=-5 to 5 by .25;
do y=-5 to 5 by .25;
z=sin(sqrt(x*x+y*y));
output;
end;
end;
proc g3d data=hat;
plot y*x=z/ctop=red;
title 'Cowboy Hat with G3D';
run;
quit;
Cowboy Hat Program Output shows the output for this program:
Cowboy Hat Program Output
If you use the DEVICE= option
in the GOPTIONS statement to route your graphics to a hardcopy device, and then you want to return to using your monitor to display graphics, you must specify a driver. Submit the following statement
to display graphics output on your monitor:
goptions device=win;
You should also use the WIN device driver to produce graphics on your display when you run your SAS job in batch mode.
You can use two methods to print output from SAS/GRAPH:
After SAS prepares output for a printer (by using either Windows printer drivers or a SAS/GRAPH printer driver),
the output is sent to the Windows Print Manager, which then queues it for printing on the device of your choice. SAS/GRAPH Generic Printer Drivers versus SAS/GRAPH Native Printer Drivers
illustrates how you can use the two sets of printer drivers within SAS/GRAPH to produce output for a given device.
SAS/GRAPH Generic Printer Drivers versus SAS/GRAPH Native Printer Drivers
The method that you choose depends on the output device you
are using. For more information, see Choosing between a SAS/GRAPH Native Driver and the WINPxxx Driver. You can control both graphics printing methods by using either the Print and Print Setup
dialog boxes or the SYSPRINT= option and the GOPTIONS DEVICE= statement.
To print a graphic using the SAS/GRAPH generic device drivers with the Windows printer drivers:
-
From the File pull-down menu, select Print Setup and verify that the Printer
field in the Print Setup dialog box contains the correct Windows printer driver and port. You can use the Print Setup dialog box to select any printer driver/port combinations that you have installed
in Print Manager. (To install new drivers and port combinations, you can use the Add Printer Wizard in Windows, which you can access
through the Windows Control Panel.)
Alternatively, you can use the SYSPRINT system option to assign the destination printer (for example,
options sysprint='HP LaserJet III';). Note that you may assign only printer driver names that have been previously configured in Windows.
-
Run your SAS/GRAPH program with the following GOPTIONS:
GOPTIONS DEVICE=WINPxxx; The value of WINPxxx you specify depends on the type of output device you use to print your graph:
-
WINPRTM
-
for black and white (monochrome) printers
-
WINPRTG
-
for grayscale printers
-
WINPRTC
-
for color printers
-
WINPLOT
-
for plotters.
The orientation of graphics output is determined by the
following:
Note:
Graphic printing is affected by the margins specified in the Page
Setup dialog box. If you modify the margins when printing graphics and your intention is to keep the graphic proportional, be sure to change the Top and Bottom margins by the same amount you change
the Left and Right margins. ![[cautend]](../common/images/cautend.gif)
SAS/GRAPH native drivers produce output in the native language of the target device. Examples of SAS/GRAPH native drivers
include:
After the SAS/GRAPH native printer driver has
produced output in the native language of the target device, SAS then routes the output to the device using Windows Print Manager. The SAS System bypasses the Windows driver that is currently
associated with the target device, but it does respect the destination specified in the Print Setup dialog box when deciding where to send the output.
To print a graph
using a SAS/GRAPH printer driver, run your SAS/GRAPH program with the following GOPTIONS:
goptions device=driver-name;
where driver-name is the name of a valid SAS/GRAPH device driver. For example,
goptions device=hpljs2;
formats the graph for the Hewlett-Packard
LaserJet Series II printer. (You can view the complete list of SAS/GRAPH drivers by submitting the PROC GDEVICE statement.)
To print a graph to a printer file (also called
a graphics stream file, or GSF) instead of directly to a printer, specify the GSFNAME option on the GOPTIONS statement with the filename or fileref that points to where you want the output. For
example:
filename graphout "graphpic.prn";
goptions gsfname=graphout gsfmode=replace
device=hpljs2;
You can preview a graph that you create and, at the same time, format it for optimal display on the device of your choice.
To preview the graph before you print it, run your SAS/GRAPH program with the following GOPTIONS statement:
goptions targetdevice=driver-name;
where driver-name is either one of the WINPxxx drivers or a SAS/GRAPH native driver.
By specifying a target
device, SAS/GRAPH can format the graph with colors and attributes appropriate for the target printer. To print the graph after it is displayed, select the File pull-down
menu and then select Print.
Note:
If you do not specify a TARGETDEVICE before you create the graph, SAS/GRAPH will prompt you (in the Print
dialog box) for a device driver name when you attempt to print the graph that you are previewing. (In most cases the WINPRTM or WINPRTC driver is specified by default.) The graph colors, orientation,
and sizing might not be optimal for the output device you specify. ![[cautend]](../common/images/cautend.gif)
When deciding whether to use SAS/GRAPH native drivers or the WINPxxx series of drivers, you need to
consider such factors as the device you are using and the type of
output you want to produce. Note the following specific considerations:
SAS/GRAPH lets you import bitmap and vector graphics that were created by other
software packages. This provides a couple of benefits:
You can import bitmap graphics into these SAS System windows:
The SAS System provides two
ways to import bitmap graphics into SAS/GRAPH:
To
import vector graphics, use the GIMPORT procedure to import computer graphics metafile (CGM) files. The imported files are stored as GRSEG catalog entries. This method preserves the individual graphic
objects in the imported graph, whereas the other two methods treat the imported graphic as a single (uneditable) bitmap. For more information about PROC GIMPORT, see SAS/GRAPH Software:
Reference.
If the tool you use to create the source graphics is a Windows application, then you can use the Windows clipboard to
copy the graphics to your SAS session.
-
From the application you used to create the graphic, select the graphic and copy it to the clipboard using the copy
procedures for your graphics tool.
-
Switch to your SAS session (or start your SAS session, if it is not already
running).
-
With the SAS/GRAPH window active, select Paste from the Edit menu (or use the GPASTE command).
The graphic is pasted into the SAS/GRAPH window.
SAS/GRAPH provides import filters to translate graphics files created in other applications to a format that you can use with the SAS
System.
You can import graphics from other applications that produce files in any of the formats
shown in Graphics Import File Formats.
To import bitmap graphics into
SAS/GRAPH:
-
With the GRAPH window active, select the Import Image... menu item from the File
menu.
-
Use the Import Image dialog box to select the source directory and graphics file. Ensure that the Format field shows the
correct source format; this indicates which import filter SAS/GRAPH will use. You can have the SAS System automatically detect the file format of the file to import by selecting AUTO as the
Format. Click on[OK].
Note:
Automatic file format detection using AUTO does not detect the DIB, EMF,
and WMF file formats ![[cautend]](../common/images/cautend.gif)
You can also include IMAGE catalog entries in your graphs. For information about including IMAGE catalog
entries, see SAS/GRAPH Software: Reference.
The SAS System provides these methods of exporting graphics created in SAS/GRAPH
for use with other word processing or desktop publishing packages, or for display on the internet or intranet:
You can also use SAS/GRAPH to create GIF and VRML files for use
with web browsers, PDF files for use with the Adobe Acrobat reader, and many other useful types of graphics files. For more information about how to create these types of files, see SAS/GRAPH
Software: Reference and the SAS online Help for SAS/GRAPH.
SAS/GRAPH provides export filters to translate graphics generated in SAS/GRAPH into formats that you can use with other applications, such as spreadsheet and desktop publishing
programs.
You can export graphics from SAS/GRAPH in any of the formats shown in Graphics Export File Formats.
To export a graph from the GRAPH
window:
-
With the GRAPH window as the active window, select the File pull-down menu and then select Export
Image....
-
In the Export Image dialog box, select the target file format.
-
Specify the directory and
filename for the exported graphic. Click on [OK].
For more information about exporting graphics to a SAS IMAGE catalog entry
from the Image editor, see the SAS online Help for SAS/GRAPH.
A quick way to export graphics from the SAS System to another Windows application is to use the
Windows clipboard. When you copy information from SAS/GRAPH to the clipboard, you can then paste that information into any application that accepts DIB, BMP or WMF
input.
To copy information from SAS/GRAPH to the clipboard:
-
From the GRAPH window, hold down the left mouse button and drag the
mouse over the portion of the graph you want to copy. A selection box marks off the selected area as you move the mouse. When you are finished, release the mouse
button.
If you do not select an area of the graph to copy, the next step will copy the entire graph to the clipboard.
-
With the
GRAPH window still active, press CTRL+C (or select Copy to Paste Buffer from the Edit
menu).
This copies the graph to the clipboard. From here, you can switch to the target application and paste the graph (typically by using the
Paste or Paste Special options in the other Windows application). For more information about how to paste information from the clipboard, see the
documentation for the other Windows application.
You can export graphs from SAS/GRAPH to other graphics packages using drivers developed specifically for those packages.
When you use computer graphics metafiles (CGMs) as the medium of transport between packages, your graph retains its separate components that you can independently edit and size. (The editing
capabilities you can
use depend on the target graphics package.)
To create a CGM from SAS/GRAPH, set GOPTIONS as follows:
FILENAME fileref 'filename.CGM';
GOPTIONS DEVICE=CGMxxxx GSFNAME=fileref
GSFMODE=REPLACE;
where CGMxxxx is the appropriate CGM driver for your target application, and filename.CGM is the name of the file you want to create.
CGM Drivers and Documentation for Popular Graphics Packages lists the graphics packages to which you can export CGMs, the appropriate drivers to use, and the SAS Institute document that
describes how to export the file and use it with the target application. You access these documents free of charge from SAS Institute's Technical Support Division on the SAS Institute web
site.
The driver names marked with an
asterisk (*) are already provided with Version 7 of the SAS System. For each driver that is not provided, the corresponding document describes how to build the driver.
To learn how to export WMF files from SAS/GRAPH software, contact SAS Institute's Technical
Support Division and ask for document TS-352C, which explains this process for several target applications. For information about creating graphics for use with Microsoft Office 97, ask for document
TS-252X. For information about creating graphics
for use with Lotus Office 97, ask for document TS-252Y.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.