SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Plots
Lesson Summary

 

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.

Creating a Basic Plot
To plot one variable against another within a set of coordinate axes, you can use the GPLOT procedure. The PROC GPLOT statement invokes the procedure. The DATA= option specifies the data set to be read. The PLOT statement requests one or more plots and specifies the variables to be plotted.

Scaling Axes
To scale the axes in your plot, you can specify the VAXIS= and HAXIS= options in the PLOT statement. You can list values or specify a range of values.

Overlaying Plots
You can also produce multiple plots on a single set of axes. To overlay multiple plots on a single set of axes, specify pairs of y-variable*x-variable relationships and the OVERLAY option in the PLOT statement.

Enhancing Plots
You can use SYMBOL statements to control the appearance of one or more plot lines. You use the VALUE= option to specify plotting symbols, the HEIGHT= option to control the height of plotting symbols, the INTERPOL= option to connect points, the WIDTH= option to specify the width of connecting lines, and the COLOR= option to specify the color of plotting symbols and lines. You have several choices for changing and cancelling SYMBOL statement options.

Using RUN-Group Processing
When you are modifying your SAS/GRAPH output, you can also take advantage of RUN-group processing. This means that when running in interactive mode, you can submit additional statements to enhance your output without resubmitting the PROC step that created it.

Selecting Observations
You can also select observations based on a condition by using a WHERE statement in your PROC GPLOT step. The WHERE statement works the same with PROC GPLOT as it does with other SAS procedures such as PROC PRINT or PROC TABULATE.

Viewing and Storing Plots
As you create plots, you can view individual graphs by scrolling in the GRAPH window or by selecting them in the Results window. To store your graphs, you can specify a temporary or permanent output catalog. You can also view and manage entries stored in catalogs.

Additional Features
In a plot of the form y*x=z plot you can generate multiple plots based on the value of a third variable, called a classification variable. There are a number of ways you can enhance your plots. You can control the minor tick marks for the vertical and horizontal axes using the HMINOR= and VMINOR= options. CAXIS= and CTEXT= options enable you to specify color for axes and text in plots. You can use the AREAS= option to fill the areas below plotted lines, PATTERN statements to define the fill colors, and NOTE statements to identify the data.

II. Syntax

To go to the page where a statement or option was presented, select a link.

LIBNAME libref  'SAS-data-library';
SYMBOL<n> <options>;
PROC GPLOT <DATA=SAS-data-set>
            GOUT=<libref.>output-catalog;
        PLOT vertical-variable-1*horizontal-variable
                   vertical-variable-2*horizontal-variable
                  < / OVERLAY> <options>;
       WHERE where-expression-1
                    <logical-operator where-expression-n>;
RUN;


III. Sample Program
     libname mylib 'd:\reports\permcat';
     symbol1 value=triangle interpol=spline
             height=1 cm width=2 color=red;
     symbol2 value=square interpol=spline
             height=1 cm width=2 color=blue;
     proc gplot data=clinic.totals2000 gout=mylib.permcat;
        plot therapy*month treadmill*month / overlay
             haxis='01' '02' '03' '04' '05' '06'
             vaxis=0 to 300 by 20;
        where therapy>treadmill;
     run;

IV. Points to Remember
  • When you specify the VAXIS= and HAXIS= options, you must enclose character values in quotes and specify them exactly as they appear in the data set.

  • In SYMBOL statements, specifying the value of one option does not affect the values of other options.

  • Temporary catalogs exist only for the duration of the current SAS session. Graphics stored in permanent catalogs can be retrieved for use in later SAS sessions.


back||next


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

Terms of Use & Legal Information | Privacy Statement