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

  • assignment statements that you explicitly output as separate observations

  • Annotate macros, which implicitly assign values to Annotate variables .

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

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 Output 24.1:

 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 annotation=triangle;  run;  quit; 

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 Figure 24.3 on page 591.

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 on page 679 and Using Annotate Macros on page 697.

Effect of Missing Values

Annotate data sets follow the same rules for missing values as any other SAS data set. (See SAS Language Reference: Concepts 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 colors list that is defined by the COLORS= graphics option, if specified, or the device s default colors 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 on page 642 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 on page 678 for details on using the (XLAST,YLAST) and (XLSTT,YLSTT) internal coordinates.




SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net