Cornell University Cornell University CISER

CISER Computing

SAS Graph Output

SAS/Graph Software enables one to generate various kinds of graphics outputs including charts, plots, maps, text and three-dimensional graphs. These graphics output files can be permanently saved or sent to printer for printing. This section describes a few ways of saving these output files on PC SAS.

SAS on PC

PC SAS displays graphics in its Graph Window. The Graph Window includes options for sending the graphics output to the printer connected to the machine for printing. Graphics output files can be permanently saved in a catalog for reading in future. The Export option in the Graph Window also allows one to translate output graphics file in a format that can be used with other applications. Below is an example to generate a pie chart in the graph window of PC SAS.

libname ssd 'u:/' ;
data temp;
input num1 @@;
cards;
1 1 1 2 2 2 2 3 3 3 3 3
; run;

proc gchart data=temp;
pie num1 /discrete fill=solid;
run;

1.   To Save a Graphics File in a Catalog

Create a LIBRARY by using a LIBNAME statement and assign a LIBREF to a folder where one wants to save their output files. Run a SAS program to create a Graphics output in the graph window of the PC.

In the graph window from the File menu choose:
    Save as -> Image
Then enter:
    Library : ssd
    Catalog: mycat (choose any name)
    Image: pie_ch (choose any name)
Then click on:
    OK

This process will save the output graphics image called "pie_ch" in a catalog named "ssd.mycat". Several graphics images with different names can be permanently saved in a catalog.

2.   To View an Image Saved in a Catalog

To view a graphics output saved in a catalog first use the LIBNAME statement to assign a libref to the directory that contains the catalog (do not repeat this if the libref has already been assigned earlier in the same session). For example:

Libname in 'u:/' ;

Then from the Globals menu choose:
    Present -> view graph
Then type in libref for library and the catalog name:
    Library: in
    Catalog: mycat
Press "enter"

This displays a list of images saved in the catalog "in.mycat". To select an image that you wish to view type "s" in the space before the name and description of the image. Click on OK.

3.   To Read an Image from a Catalog to the Graph Window

To read an image in the graphics window the image is first displayed in the image editor window. The editor in the window is used to make a copy of the image that is then pasted to the Graph Window. Below is the process to do that.

Assign a libref to the directory by using the LIBNAME statement (do not repeat this if the libref has already been assigned earlier in the same session). For example: Libname in 'u:/' ;

  • To read graphics image in image editor
    To read a graphics output saved in a catalog first bring up the image editor window by choosing:
        Globals -> Present -> View Imag
    Then from image editor choose:
        File -> open -> image object
    Type in libref for library and its catalog name:
        Library: in
        Catalog: mycat
    Press "enter"


    Select an image that you wish to display by typing "s" in the space before the name and description of the image. Click on OK.
  • To copy a section of image from image editor to graph window
    To select an area of the image for copying and pasting on graph window, from image editor menu choose:
        Edit -> select
        Edit -> copy

    Then open the graph window by choosing:
        Globals -> graphs
    To paste image on the graph window choose:
        Edit -> paste

    This displays the image in the graph window where it can be sent to the printer connected to the machine for printing. The Export option in the Graph Window also allows one to translate the image in a format that can be used with other applications.

4.   To Export a Graphics Image

The Export option in the Graph Window allows one to translate output graphics image in a format that can be used with other applications. To export an image displayed in the graphics window, from the menu choose:

File -> Export

In the Export dialog box select the target file format and specify the directory and filename for the exported image, then click on "OK". An exported file with extension of ".bmp" can be opened in Microsoft Windows Paintbrush, whereas, a postscript file with extension of ".ps" can be processed in Ghost View.