Example of Producing an Annotated ODS Graphics Designer Graph for Publication

About This Example

In this example, an environmental engineering company wants to graph its stock closing values for the past few months. The company plans to include the graph in an online color presentation. Here are the high-level steps:
  1. Create the graph using the ODS Graphics Designer.
  2. Produce an editable graph using the SGDESIGN procedure with an ODS destination statement.
  3. Modify the graph using the ODS Graphics Editor and save it as a PNG file. Modifications include the following:
    • changing the graph style and the color of the title
    • adding the company logo to the graph
Note: Within these high-level steps, the exact steps can vary. For example, some of the formatting that occurs in the ODS Graphics Editor could be done in the ODS Graphics Designer instead. The instructions here provide one way to create the final graph.
Output for the Stock Closing Example
Output for the Stock Closing Example

Data Used for This Example

The company wants to include in a presentation its stock closing values for the months July 2010 through June 2011. Here is the data set that is used.
data companyStock;
  informat day date7.;
  input day close;
  format day worddate3.;
  format close dollar4.;
  datalines;
  30Jul10  80
  31Aug10  84
  30Sep10  82
  29Oct10  77
  30Nov10  85
  24Dec10  85
  31Jan11  87
  28Feb11  90
  31Mar11  93
  29Apr11  95
  31May11  99
  30Jun11  102
  ;
run;

Create the Graph Using the ODS Graphics Designer

Step One: Create the Graph and Assign Data

  1. In SAS, create the data set that you need for this example. Execute the code found in Data Used for This Example.
  2. Select Toolsthen selectODS Graphics Designer. The designer opens and displays the Graph Gallery.
  3. On the Basic tab of the Graph Gallery, double-click the Series Plot icon.
    Graph Gallery
    The Assign Data dialog box appears.
  4. In the Assign Data dialog box, complete these steps:
    • Select WORK from the Library drop-down list.
    • Select COMPANYSTOCK from the Data Set drop-down list.
    • Select DATE from the X drop-down list.
    • Select CLOSE from the Y drop-down list.
  5. Click OK.

Step Two: Customize the Title, Footnote, and Axis Labels

  1. Double-click the placeholder title. The placeholder text is highlighted:
    title text box
  2. In the text box, enter Stock Closing Prices.
  3. In the bottom left corner of the graph, double-click the placeholder footnote. The placeholder text is highlighted.
  4. In the text box, enter Years: 2010–2011.
  5. Right-click the X axis label and select Axis Properties. The Cell Properties dialog box appears and displays the Axes tab.
  6. In the Label text box, enter Month.
  7. From the Axis list box, select Y.
  8. In the Label text box, the word close is lower case. Capitalize Close.
  9. Click OK.

Step Three: Resize and Save the Graph

  1. To resize the graph:
    1. Right-click the graph and select Graph Properties. The Graph Properties dialog box appears.
      Graph Properties dialog box
    2. In the Width list box, specify 480. The width and height are measured in pixels. Clicking an arrow changes the value by 10 pixels.
      To resize the height proportionally, make sure that the Keep Aspect Ratio check box is selected.
    3. Click OK.
  2. To save the graph:
    1. Select Filethen selectSave As.
    2. Save the file to the desired location. Specify the name that you want for the file. For example, you might enter companystock. The file type SGD Files (*.sgd) is selected by default.
    3. Click Save.
Here is the graph output.
Stock Closing Example in ODS Graphics Designer
Stock Closing Example in ODS Graphics Designer

Generate an Editable Graph

In this step, you generate a graph that can be edited in the ODS Graphics Editor. To do this, use the SGDESIGN procedure with an ODS destination statement.
In SAS, execute the SGDESIGN procedure and reference the SGD file that you created for the example. Here is sample code:
ods listing sge=on;
proc sgdesign sgd="C:\SGDFiles\companystock.sgd";
run;
Note the following:
  • To create an editable graph, specify the SGE= ON option in an ODS destination statement.
  • For the SGD= value, specify the path and name of the SGD file that you created for the example.
The example does not need to specify the WORK.COMPANYSTOCK data set. By default, the SGDESIGN procedure uses the data set that is defined in the SGD file. That data set remains available as long as the SAS session is open.

Annotate the Graph Using the ODS Graphics Editor

Step One: Open the Graph in the ODS Graphics Editor

  1. Click the expansion icon in the SAS Results window to expand the list of graphs that you created.
  2. Double-click the SGE file, which is identified by the ODS Graphics Editor icon icon.
    The ODS Graphics Editor opens and displays the graph for editing.
Note: You cannot edit an ODS graph on z/OS systems.

Step Two: Change the Graph Style and the Title Color

  1. With your graph displayed, select Formatthen selectStylethen selectAnalysis from the main menu. The style of the graph changes.
  2. Right-click the title and select Compose Rich Text from the pop-up menu. The Compose Rich Text dialog box appears.
    Compose Rich Text dialog box
    Do the following:
    1. Select all of the text in the Text box.
    2. Select the green color green color from the color drop-down list Font color list box.
    3. Click OK.

Step Three: Add an Image to the Graph

In this step, you add an image, such as a logo, to a graph. For the company stock example, the image is a company logo. You can substitute any small image that you have at your site.
  1. Click the image icon from the Graph toolbar, or select Insertthen selectImage from the main menu.
  2. From the Image dialog box that displays, select and open the image that you want to insert.
    The image appears in the center of the graph.
  3. Click and drag the image to the bottom right corner of the graph.
  4. If you need to resize the image, select the image and drag one of the circles that appear around the image.
    You can maintain the ratio of width to length. To do this, position your cursor on a corner circle, press SHIFT, and drag the corner circle.

Step Four: Save the Graph

  1. Select Filethen selectSave As from the menu.
  2. Select the directory where you want the graph to be saved.
  3. Select save options as follows:
    • Select the PNG file type. This option saves the graph as a flat image. The graph in this format cannot be edited, though it can be annotated.
      Tip
      If you might later want to reopen and edit the file, save it first in SGE format.
    • Set the resolution to 100 DPI (default). Changing the DPI changes the size of the image.
  4. Enter the name of the graph in the File name field.
  5. Click Save.