SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Enhancing and Exporting Charts and Plots
Exporting Graphs


Exporting SAS/GRAPH Output Using Program Statements

To export SAS/GRAPH output using program statements, you specify

  • a destination for the output
  • a device driver that creates the type of graphics output that you want.


Specifying an Output Destination

To specify an output destination, you

  • use a FILENAME statement to assign a fileref to the external file where you want to send the output

General form, FILENAME statement:
FILENAME fileref 'filename';

where

  • fileref is a valid SAS name you associate with an external file. The fileref must be 1 to 8 characters in length, begin with a letter (A-Z) or an underscore (_), and continue with any combination of numbers, letters, or underscores. You can also use the dollar sign ($), pound sign (#), and at sign (@) in filerefs.

  • filename is the fully qualified name or location of the file.
Note: The filename must be the complete physical name of the external file and must include a file extension that indicates what type of graphics file you are creating, such as .GIF for a GIF file.


General form, GOPTIONS statement:
GOPTIONS <options-list>;

where options-list can be one or more graphics options.

Note: With the exception of RESET=, graphics options can be listed in any order in a GOPTIONS statement. RESET= should be the first option in the GOPTIONS statement.


For example, the following FILENAME statement assigns the fileref Mygif to the file C:\My SAS Files\Hbar1.gif in the Windows environment. Then the GOPTIONS statement specifies Mygif as the output destination for the SAS/GRAPH procedure that follows.
     filename mygif 'c:\my sas files\hbar1.gif';
goptions gsfname=mygif;
SAS/GRAPH statements...
run;


Specifying a Device Driver

To specify the device driver, you use the DEVICE= graphics option in the GOPTIONS statement.


General form, DEVICE= option:
DEVICE=device-driver

where device-driver is a valid device driver.


For example, to specify your output as a GIF file, you add the following DEVICE= option:
     filename mygif 'c:\my sas files\hbar1.gif';
goptions gsfname=mygif device=gif;
SAS/GRAPH statements...
run;


Example: Exporting Two Charts

The following SAS program creates a bar chart and a pie chart, each stored in a separate GIF file.

     filename bargif 'g:\images\barchart.gif';
goptions gsfname=bargif device=gif;
proc gchart data=clinic.admit;
vbar actlevel / sumvar=fee;
run;
filename piegif 'g:\images\piechart.gif';
goptions gsfname=piegif device=gif;
proc gchart data=clinic.stresstest;
pie tolerance;
run;
quit;

back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement