Previous Page | Next Page

Using Annotate Data Sets

Creating an Annotate Data Set

Once you have determined what you are going to draw and how you want it to appear in the output, you need to build an Annotate data set. Although there are many ways to create SAS data sets, the most commonly used method for creating Annotate data sets is with a DATA step that uses either

Most of the examples in this documentation use a DATA step with assignment statements. For more information on creating SAS data sets, see SAS Data Sets.


Using the DATA Step

When you use the SAS DATA step with assignment statements, each statement provides a value for an Annotate variable. After you have assigned all of the variable values for an observation, you must use an OUTPUT statement to write the observation to the data set. For example, the following statements create the TRIANGLE data set shown in Listing of the Annotate Data Set TRIANGLE:

data triangle;

      /* declare variables */
   length function style color $ 8 text $ 25;
   retain hsys xsys ysys "3";

      /* create observation to draw the title */
   function="label"; x=20; y=85; position="6";
      text="Sample Annotate Graphics";
      style="swissb"; color="green"; size=6;
      output;

      /* create observations to draw the triangle */
   function="move"; x=28; y=30; output;
   function="draw"; x=68; y=30; size=.8; line=1;
      color="red"; output;
   function="draw"; x=48; y=70; output;
   function="draw"; x=28; y=30; output;
run;

proc ganno annotate=triangle;
run;
quit;

INF

Notice that a RETAIN statement sets the values of the HSYS, XSYS, and YSYS variables. RETAIN statements are useful when you want to select the values for variables that are required for many functions and the value is the same for all of them.

The SIZE, LINE, and COLOR variables are included with only the first DRAW function. Using this method to create the data set, the values set in the first DRAW function carry over to subsequent DRAW functions.

The PROC GANNO takes as input the annotate data set "triangle" created by the previous DATA step and creates the output shown in Annotate Output from the TRIANGLE Data Set.


Using Annotate Macros in the DATA Step

A set of Annotate macros is provided in the SAS sample library. You can use macro calls in a DATA step to create observations in an Annotate data set. You can also use Annotate macros and explicit variable assignments together in the same DATA step. For complete information, see Annotate Macros and Using Annotate Macros.


Effect of Missing Values

Annotate data sets follow the same rules for missing values as any other SAS data set. (See Missing Values for information on the effect of missing values in a data set.)

Variables that have a missing value use a default value. For example, if the COLOR variable has a missing value, then the first color in either the color list that is defined by the COLORS= graphics option, if specified, or the device's default color list is used. If the FUNCTION variable has a missing value, LABEL is used. If the X variable is missing, the value of the XLSTT internal coordinate is used for text functions and the XLAST internal coordinate is used for nontext functions. See Annotate Variables for the default value of each Annotate variable.

You probably should not depend on this effect when you create an Annotate data set. If the data set is structured so that observations depend on prior observations setting attributes for them, then you may have extra work to do if you change the order of observations later.

Sometimes missing values are required to produce the desired results. If you have calculated the coordinates of a point and have the values stored in (XLAST,YLAST) or (XLSTT,YLSTT), you can force Annotate to use the internal coordinates by supplying missing values for the X and Y variables. See Annotate Internal Coordinates for details on using the (XLAST,YLAST) and (XLSTT,YLSTT) internal coordinates.

Previous Page | Next Page | Top of Page