SAS Institute. The Power to Know

SAS/GRAPH(R) 9.2: Graph Template Language Reference

Previous | Next
Key Concepts

ODS Graphics Environment

Although the ODS GRAPHICS statement is not among the requirements listed in "Minimum Requirements to Generate a Plot", it manages the settings of the ODS Graphics environment and is a statement you will probably use frequently in your SAS sessions. For example, the ODS GRAPHICS statement provides options that control the physical aspects of your graphs, such as the image size and the name of the image file that is created for the graph.

The default image size of 640 pixels by 480 pixels (4:3 aspect ratio) for ODS Graphics is set in the SAS Registry. You can change the image size using the WIDTH= and/or HEIGHT= options on the ODS GRAPHICS statement. To name the output image file, use the IMAGENAME= option.

The following ODS GRAPHICS statement sets a 320 pixel width for the graph and names the output image file modelfit :

  
 ods graphics / width=320px 
                imagename="modelfit" reset; 
  
 proc sgrender data=sashelp.class template=modelfit; 
 run; 
  
 ods graphics off;
 
  • The WIDTH= option sets the image width to 320 pixels. Because no HEIGHT= option is used, SAS uses the design aspect ratio of the graph to compute the appropriate height. (The width of 320px is half the default width, so SAS will set the height to 240px, which is half the default height.)
  • The IMAGENAME= option sets the name of the output image file to modelfit . The RESET option ensures that each time the graph is produced, the previous version of the image file is replaced. Otherwise, image names are incremented (modelfit1, modelfit2, and so on) every time the graph is produced.

In general, it is good practice to specify only one sizing option without the other - just the WIDTH= option or just the HEIGHT= option. That way SAS will maintain the design aspect ratio of the graph, which may be important for many graphs. For example, a graph that has multiple columns or a statistics table on the side needs a wide aspect ratio. Specifying both width and height in such cases may produce unpredictable results.

Note. Size settings on the ODS GRAPHICS statement affect all of the graphs that are rendered in the SAS session, unless they are changed by another ODS GRAPHICS statement. The size for a graph produced by an individual template can be set with the DESIGNWIDTH= and DESIGNHEIGHT= options on the BEGINGRAPH statement. Size settings on the ODS GRAPHICS statement override size settings on the BEGINGRAPH statement and remain in effect unless they are changed on another ODS GRAPHICS statement or ODS GRAPHICS are turned off.

For more information on using the ODS GRAPHICS statement, see the usage guide.

Previous | Next | Top of Page