Producing Graphics


Producing Graphics on Your Display

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 SAS 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; 

The following display shows the output for this program:

click to expand
Display 6.5: 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.

If you specify that your program output is to be displayed in HTML, your graphic is converted to a .GIF file and stored in the same folder as your SAS data set. For more information, see SAS Output Delivery System: User s Guide .

Printing Graphics

You can use two methods to print output from SAS/GRAPH:

  • Use the SAS/GRAPH generic driver with the Windows printer driver for your device (supplied with Windows or with your output device). This method allows SAS/GRAPH to send generic graphics commands to the Windows printer driver, which then translates the commands to a format that the printer can use.

  • Use a SAS/GRAPH printer driver to create a printer-specific graphics stream that can be sent directly to the device. When you use a SAS/GRAPH printer driver, SAS bypasses the Windows printer drivers and creates printer-ready output for your device. The SAS/GRAPH printer driver is also called a SAS/GRAPH native print driver, which means that the driver creates output by using the printer language that is native to the target device. SAS/GRAPH printer drivers under Windows are similar to those used by SAS on mainframe and UNIX operating environments.

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 printer, which then queues it for printing on the device of your choice. Figure 6.1 on page 185 illustrates how you can use the two sets of printer drivers within SAS/GRAPH to produce output for a given device.

click to expand
Figure 6.1: SAS/GRAPH Generic Printer Drivers Compared with SAS/GRAPH Native Printer Drivers

The method that you choose depends on the output device that you are using. For more information, see Choosing between a SAS/GRAPH Native Driver and the WINP xxx Driver on page 187. 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.

Using the SAS/GRAPH Generic (WINPxxx) Drivers

To print a graphic by using the SAS/GRAPH generic device drivers with the Windows printer drivers:

  1. From the File pull-down menu, select Print Setup and verify that the Printer field in the Print Setup dialog box lists 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. (To install new drivers and port combinations, you can use the Add Printer Wizard in Windows.)

    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.

  2. Run your SAS/GRAPH program with the following graphic options:

     goptions device=winp  xxx  ; 

    The value of WINP xxx you specify depends on the type of output device that 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:

  • If you specify the ROTATE= graphic option, the output is oriented according to the value that you specify for ROTATE. For example, suppose you specify

     goptions rotate=landscape 

    Then the output is oriented as landscape, regardless of the settings in the Print Setup dialog box.

  • If you do not use the ROTATE= graphic option, the output is oriented according to the settings in the Print Setup dialog box.

Note: Graphics printing is affected by the margins that are 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.

Using the SAS/GRAPH Native Printer Drivers

SAS/GRAPH native drivers produce output in the native language of the target device. Examples of SAS/GRAPH native drivers include:

PS

produces Postscript output.

HPLJS3

produces output in the PCL5 language that is used by Hewlett Packard LaserJet III printers.

HP7550

produces HPGL output that is used by Hewlett “Packard 7550 plotters.

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 the Windows printer. SAS bypasses the Windows driver that is currently associated with the target device, but it does respect the destination that is specified in the Print Setup dialog box when deciding where to send the output.

To print a graph by using a SAS/GRAPH printer driver, run your SAS/GRAPH program with the following graphic options:

 goptions device=  driver-name  ; 

where driver-name is the name of a valid SAS/GRAPH device driver. Consider this example,

 goptions device=hplj5p3; 

This statement formats the graph for the Hewlett Packard LaserJet Series V 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, use the GSFNAME option on the GOPTIONS statement and use a filename or a fileref to specify where you want the output. For example:

 filename graphout "graphpic.prn";  goptions gsfname=graphout gsfmode=replace           device=hpljs2; 
Printing and Previewing from the GRAPH Window

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 WINP xxx drivers or a SAS/GRAPH native driver.

By specifying a target device, SAS/GRAPH can format the graph with colors and attributes that are 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 target device 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.

Choosing between a SAS/GRAPH Native Driver and the WINPxxx Driver

When deciding whether to use SAS/GRAPH native drivers or the WINP xxx series of drivers, consider such factors as the device that you are using and the type of output that you want to produce. Note the following specific considerations:

  • If no Windows printer driver is available for your device, use a SAS/GRAPH native driver.

  • If you have a device for which there is no SAS/GRAPH native driver, use the WINP xxx driver, if there is a Windows printer driver available for the device. In cases where a new model of hardcopy device becomes available between releases of SAS and the hardware vendor provides a new Windows driver that uses new features of the device, you can use a WINP xxx driver to take advantage of those features.

  • If you want to use options such as HSIZE= or VSIZE= to customize the size specifications used in your graph, using SAS/GRAPH native drivers usually produces more reliable results.

  • To use TrueType fonts in your SAS/GRAPH output, use one of the WINP xxx drivers and specify the font just as you would specify one of the installed hardware fonts for your printer. For more information about TrueType fonts, see Using TrueType Fonts with SAS/GRAPH Software on page 613

Importing Graphics from Other Applications

SAS/GRAPH lets you import bitmap and vector graphics that were created by other software packages. This provides these benefits:

  • You can create your graphic using another graphics editor, then import the graphic into SAS/GRAPH to produce output on a specialized device.

  • You can merge clip art and graphs from other applications with the graphs that you create in SAS/GRAPH.

You can import bitmap graphics into these SAS windows:

  • GRAPH window. The imported graphic becomes a new GRSEG entry in the current catalog.

  • Graphics Editor. The imported graphic becomes part of the current graph.

  • Image editor window. The imported graphic becomes a new image.

SAS 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 methods treat the imported graphic as a single (uneditable) bitmap. For more information about PROC GIMPORT, see SAS/GRAPH Reference, Volumes 1 and 2 .

Pasting Graphics from the Windows Clipboard

If the tool that 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 as follows :

  1. From the application that you used to create the graphic, select the graphic and copy it to the clipboard using the copy procedures for your graphics tool.

  2. Switch to your SAS session (or start your SAS session, if it is not already running).

  3. With the SAS/GRAPH window active, select Paste from the Edit menu. The graphic is pasted into the SAS/GRAPH window.

Importing a Graphics File from within a SAS/GRAPH Window

SAS/GRAPH provides import filters to translate graphics files that were created in other applications to a format that you can use with SAS.

You can import graphics from other applications that produce files in any of the formats that are shown in the following table:

Table 6.7: Graphics Import File Formats

Graphics File Format

File Extension

Microsoft Windows bitmap

BMP

Microsoft Windows metafile

WMF

enhanced metafile

EMF

Device independent bitmap

DIB

JPEG format

JPG

graphic interchange format (GIF)

GIF

tag image file format (TIFF)

TIF

PC Paintbrush

PCX

Truevision Targa

TGA

Encapsulated PostScript Interchange (EPSI)

PS

Portable Network Graphics

PNG

Photo CD image

PCD

Portable Pixmap

PBM

X Window bitmap

XBM

X Window dump

XWD

To import bitmap graphics into SAS/GRAPH:

  1. Make the GRAPH window the active window and then select Import Image from the File menu.

  2. Use the Import Image dialog box to select the source directory and graphics file. Be sure that the Format field shows the correct source format; this indicates which import filter SAS/GRAPH will use. You can have SAS automatically detect the file format of the file to import by selecting AUTO as the format. Click OK .

    Note: Automatic file format detection using AUTO does not detect the DIB, EMF, and WMF file formats

You can also include IMAGE catalog entries in your graphs. For information about including IMAGE catalog entries, see SAS Help and Documentation.

Exporting Graphics for Use with Other Applications

SAS provides the following 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 Reference, Volumes 1 and 2 and SAS/GRAPH in SAS Help and Documentation.

Exporting a Graphic to a File from a SAS/GRAPH Window

SAS/GRAPH provides export filters to translate graphics that were 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 that are shown in the following table:

Table 6.8: Graphics Export File Formats

Graphics File Format

File Extension

Microsoft Windows bitmap

BMP

Microsoft Windows metafile

WMF

enhanced metafile

EMF

Device independent bitmap

DIB

JPEG format

JPG

graphic interchange format (GIF)

GIF

tag image file format (TIFF)

TIF

Adobe PostScript

PS

Encapsulated PostScript Interchange (EPSI)

PS

Portable Network Graphics

PNG

Portable Pixmap

PBM

To export a graph from the GRAPH window:

  1. Make the GRAPH window the active window and select Export Image from the File pull-down menu.

  2. In the Export Image dialog box, select the target file format.

  3. Specify the directory and filename for the exported graphic. Click OK .

For more information about exporting graphics to a SAS IMAGE catalog entry from the Image editor, see SAS Help and Documentation for SAS/GRAPH.

Pasting Graphics from SAS/GRAPH into other Windows Applications

A quick way to export graphics from SAS 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:

  1. From the GRAPH window, hold down the left mouse button and drag the mouse over the portion of the graph that 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.

  2. 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. You can then return to the target application and paste the graph (typically by using the Paste or Paste Special options in the target Windows application). For more information about how to paste information from the clipboard, see the documentation for the other Windows application.

Creating CGM Files for Export to Other Applications

You can export graphs from SAS/GRAPH to other graphics packages by using drivers that were 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 so that you can independently edit and size it. 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=cgm  xxxx  gsfname=  fileref  gsfmode=replace; 

where CGM xxxx is the appropriate CGM driver for your target application, and filename .CGM is the name of the file that you want to create. Table 6.9 on page 191 lists the graphics packages to which you can export CGMs, the appropriate drivers to use, and the SAS documents that describe how to export files and how to use them with the target application. You access these documents from SAS Institute s Technical Support Division on the SAS Institute Web site.

Table 6.9: CGM Drivers and Documentation for Popular Graphics Packages

Package

Suggested Driver

Document

Aldus PageMaker

CGMAPMA*

TS-252F

Aldus Persuasion

CGMAPSA*

TS-252D

BPS 35 MM Express

CGM35

TS-252

BorlandQuattroPro(Windows)

CGMBQWC

TS-252J

Borland Quattro Pro (DOS)

CGMBQA*

TS-252

CorelDRAW 5

CGMCOR5L

TS-252R

Frame Tech FrameMaker

CGMFRCA* CGMFRGA*

CGMFRMA* PSCFRAME

PSGFRAME PSMFRAME

TS-252H

Harvard Graphics 2.12 for DOS

CGHHG

TS-252

Harvard Graphics 3.0 for DOS

CGMHG3A*

TS-252A

Harvard Graphics for Windows

CGMHGWA*

TS-252C

Harvard Graphics 3.0 for Windows

CGMHG3L

TS-252T

ImageBuilder

CGMIMG

TS-252

Interleaf 5

CGMCILFC* CGMGILFG*

CGMMILFM* PSILEAFC

PSILEAFG PSILEAFM

TS-252I

Lotus Ami Pro 3.0

CGMAM3C* CGMAM3G

CGMAM3M

TS-252M

Lotus Ami Pro 2.0

CGMAMIA

TS-252

Lotus Freelance for DOS

CGMFLALJ* CGMFLAPL*

CGMFLAPT*

TS-252

Lotus Freelance for Windows 2.0

CGMFL2C* CGMFL2G

CGMFL2M

TS-252K

Lotus Freelance for Windows 1.0

CGMFLWA*

TS-252

Lotus 1-2-3 4.0

CGM123C*

TS-252N

Lotus 1-2-3

CGM123

TS-252

Lotus Office 97

CGMLOT97 CGMLT97P

TS-252Y

Microsoft Word for Windows 6.0

CGMMW6C* CGMMW6G

CGMMW6M

TS-252L

Microsoft Word for Windows 2.0

CGMMWWC*

TS-252B

Microsoft PowerPoint

CGMMPPA

TS-252E

Microsoft Office 97

CGMOFF97 CGMOF97P

TS-252X

Polaroid CI3000

CI3000

TS-252

WordPerfect 5.1 for DOS

CGMWPCA CGMWPCAP*

CGMWPGA CGMWPGAP*

CGMWPMA CGMWPMAP*

TS-252G

WordPerfect 5.2 for Windows

CGMWPWA*

TS-252

WordPerfect 6.0 for Windows (Beta)

CGMWP6C CGMWP6G

CGMWP6M

TS-252O

WordPerfect 6.0A for Windows

CGMWPGCA

TS-252P

WordPerfect 6.1 Windows

CGMWPGIL

TS-252S

WordPerfect Suite 8

CGMWP80P

TS-252Z

WordPerfect 6.0 for UNIX

CGMWPUXL

TS-252U

WordPerfect Presents for DOS

CGMWPCA* CGMWPGA*

CGMWPMA*

TS-252G

Zenographics Pixie

CGMPIX

TS-252

The driver names that are marked with an asterisk (*) are already provided with SAS 9.1. For each driver that is not provided, the corresponding document describes how to build the driver.

Creating WMF (Windows Metafile) Files for Export to Other Applications

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. For information about creating graphics for use with Corel Word Perfect Suite 8, ask for document TS-252Z.

Additional Resources

For full details about using SAS/GRAPH software, see SAS/GRAPH Reference, Volumes 1 and 2 . For further details about using graphics and fonts with SAS under Windows, see Using TrueType Fonts with SAS/GRAPH Software on page 613.




SAS 9.1 Companion for Windows
SAS 9.1 Companion for Windows (2 Volumes)
ISBN: 1590472004
EAN: 2147483647
Year: 2004
Pages: 187

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net