Running SASGRAPH Programs


Running SAS/GRAPH Programs

Modes of Operation

There are several ways to run a SAS program. You can use

  • SAS windowing environment that gives you a text editor from which to submit programs, windows for the SAS log and SAS output, and many other facilities

  • interactive line mode, in which you submit programs one line at a time

  • noninteractive mode, which executes a SAS program (stored in a file) in your current terminal session

  • batch mode, which executes a SAS program (stored in a file) in a separate session.

The mode you use determines whether the graphics output displays on your monitor. If you use the SAS windowing environment, interactive line mode, or noninteractive mode, the SAS/GRAPH program can display graphics output on your monitor as well as store the output in a catalog.

If you use batch mode, the graphics output is not displayed on your monitor. In this case, your program must send the graphics output to a hardcopy device, permanent catalog, or a graphics stream file. See Chapter 4, SAS/GRAPH Output, on page 47 for more information on the destination of graphics output.

Regardless of how you run your programs, SAS/GRAPH software uses the values stored in the device entry or specified by graphics options in a GOPTIONSChapter 36, The GOPTIONS Procedure, on page 1075 statement to determine how to handle the graphics output.

Running in Batch Mode

When you run in batch mode, some SAS/GRAPH device drivers such as device=GIF attempt to use fonts from the X server to annotate the graph output. This can result in a "CANNOT OPEN XDISPLAY" warning if the DISPLAY environment variable has not been set.

To avoid this warning message, you can run in batch mode with the -NOTERMINAL option. Although this suppresses the warning message, it has the disadvantage of not allowing use of the high quality fonts that are available with the X server.

A better solution is to set your DISPLAY environment variable to any available X server. This not only removes warning messages concerning the XDISPLAY, but it also improves the quality of text in GIF output by using fonts avilable from the X server. The GIF driver does not open any windows on the display referenced by the DISPLAY variable.

An alternative solution does not require a display to be set. FreeType font support can be enabled by setting CHARREC[0] in the device entry to use a TrueType or Type1 font available on your system as follows :

 libname gdevice0 '.';  proc gdevice c=gdevice0.devices nofs;     copy gif from=sashelp.devices newname=mygif;     mod mygif charrec=(0,1,1, 'SAS Monospace', 'Y');  quit;  goptions reset=all dev=mygif ftext='Arial';  title h=5  'Arial';  proc gslide border;run;quit; 

SAS Monospace is available on all hosts and other fonts can be made available by running PROC FONTREG.

 proc fontreg fontpath 'directory_containing_TT_or_Type1_fonts';run; 

FreeType font support is also available with the Universal GIF driver.

 options dev=sasprtc printerpath=gif;  proc gtestit pic=1;run; 

RUN- Group Processing

You can use RUN-group processing with the GCHART, GMAP, GPLOT, GREPLAY, and GSLIDE procedures to produce multiple graphs without restarting the procedure every time.

To use RUN-group processing, you start the procedure and then submit multiple RUN-groups. A RUN-group is a group of statements that contains at least one action statement and ends with a RUN statement. It can contain other SAS statements such as AXIS, BY, GOPTIONS, LEGEND, TITLE, or WHERE. As long as you do not end the procedure, it remains active and you do not need to resubmit the PROC statement.

To end RUN-group processing, submit a QUIT or RUN CANCEL statement, or start a new procedure.

Note: When using SAS/GRAPH with the ODS statement, it is best to use a QUIT statement after each procedure that uses RUN-group processing, rather than relying on a new procedure to end the processing. Running too many procedures without an intervening QUIT statement can use up so much memory as to crash the system (depending, of course, on how many other processes are running). Also, note that failing to do a QUIT before doing an ODS CLOSE results in the process memory not being freed at all.

With global and local statements

Global statements and NOTE statements that are submitted in a RUN-group affect all subsequent RUN-groups until you cancel the statements or exit the procedure. For example, each of these two RUN-groups produces a plot and both plots display the title defined in the first RUN-group:

 /* first run group*/  proc gplot data=sales;     title1 'Sales Summary';     plot sales*model_a;  run;        /* second run group */     plot sales*model_b;  run;  quit; 

With BY statements

BY statements persist in exactly the same way. Therefore, if you submit a BY statement within a RUN-group, the BY-group processing produces a separate graph for each value of the BY variable for the RUN-group in which you submit it and for all subsequent RUN-groups until you cancel the BY statement or exit the procedure. Thus, as you submit subsequent action statements, you continue to get multiple graphs (one for each value of the BY variable). For more information, see BY Statement on page 141.

With the WHERE Statement

The WHERE statement enables you to graph only a subset of the data in the input data set. If you submit a WHERE statement with a RUN-group, the WHERE definition remains in effect for all subsequent RUN-groups until you exit the procedure or reset the WHERE definition.

Using a WHERE statement with RUN-group processing follows most of the same rules as using the WHERE statement outside of RUN-group processing with these exceptions:

  • With the GMAP procedure, the WHERE variable must be in the input data set.

  • With a procedure that is using an Annotate data set, the following requirements must be met:

    • The ANNOTATE= option must be included in the action statement.

    • The WHERE statement must be executed before the action statement.

    • The WHERE variable must occur in the Annotate data set.




SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

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