Previous Page | Next Page

Language Reference

ODSGRAPH Call

CALL ODSGRAPH( name, template, matrix1 <, matrix2, ..., matrix13> ) ;

The ODSGRAPH subroutine renders an ODS statistical graph that is defined by a template.

The input arguments to the ODSGRAPH subroutine are as follows:

name

is a character matrix or quoted literal that assigns a name to the graph. The name is used to identify the output graph in the SAS Results window.

template

is a character matrix or quoted literal that names the template used to render the graph.

matrix

is a matrix whose columns are supplied to the template. You can specify up to 13 arguments. The name of each column must be specified by using the MATTRIB statement or the COLNAME= option in a READ statement.

The ODSGRAPH subroutine (which requires a license for SAS/GRAPH) renders a graph defined by the input template. Data for the graph are in the columns of the matrix arguments. Column names are assigned to the matrices by using the MATTRIB statement or by using the COLNAME= option in a READ statement. This is illustrated in the following example, which produces a three-dimensional surface plot:

   proc template;
     define statgraph SurfacePlot;
       BeginGraph;
       layout overlay3d;
         surfaceplotparm x=x y=y z=z / surfacetype=fill;
       endlayout;
       EndGraph;
     end;
   run;

   title "Surface Plot";
   ods html;

   proc iml;
   XDiv = do( -5, 5, 0.25 );
   YDiv = do( -5, 5, 0.25 );
   x = j( ncol(XDiv)*ncol(YDiv), 1 );
   y = j( ncol(XDiv)*ncol(YDiv), 1 );
   k = 1;
   do i = 1 to ncol(YDiv);
      do j = 1 to ncol(XDiv);
         x[k] = XDiv[j];
         y[k] = YDiv[i];
         k = k + 1;
      end;
   end;
   z = sin( sqrt( x##2 + y##2 ) );
   matrix = x || y || z;
   mattrib matrix colname={"x" "y" "z"};
   call odsgraph("surface","SurfacePlot",matrix);
   quit;

   ods html close;

In the example, the TEMPLATE procedure defines a template for a surface plot. The ODSGRAPH subroutine calls ODS to render the graph by using the layout in the template. (The example renders the graph in the HTML destination; you can also render the graph in the default listing destination.) The data for the graph are contained in a matrix. The MATTRIB statement associates the columns of the matrix with the variable names required by the template.

You can also create graphs from data read from a data set. If x, y, and z are variables in a data set, then the following statements plot these variables:

   use myData;
   read all into matrix [colname = c];
   call odsgraph("surface","SurfacePlot",matrix);

Since column names created via a READ statement are permanently associated with the INTO matrix, you do not need to use a MATTRIB statement for this example.

The sample programs distributed with SAS/IML software includes other examples of plots available by using ODS Statistical Graphics.

Previous Page | Next Page | Top of Page