Using Annotate Macros


Macro Structure

The general form of an Annotate macro is

 %MACRO (parameters); 

In general, the macro name represents a function and the parameters contain the values for the variables that can be used with the function. All macros except DCLANNO, SYSTEM, and SEQUENCE output an observation.

The parameters are either numeric or character. Numeric parameters can be numeric constants or numeric variable names that have been initialized to the appropriate value. Most character parameters must be expressed as literals, that is character strings without quotation marks. Exceptions are the text values that are used with the COMMENT and LABEL macros, which can be expressed as character strings enclosed in quotation marks or as character variable names.

The Annotate facility assigns the parameter values to the corresponding Annotate variables. Therefore, the observations in an Annotate data set that is created with macros that look the same as the ones that you created with assignment statements.

Making the Macros Available

To use Annotate macros, you must provide your program with access to the data set that contains the macros, and you must compile the macros before you use them. Check with your SAS Software Consultant to find out if the fileref for the data set that contains the Annotate macros that are supplied with SAS/GRAPH software is allocated automatically at your site. Then access the Annotate macros in one of these ways:

  • If the fileref is not set automatically, find out where the Annotate macros are stored and allocate a fileref that points to the data set:

     filename fileref 'external-file'; 

    Then include the Annotate macros in your session:

     %include fileref (annomac); 
  • If the fileref is set automatically, compile the Annotate macros and make them available by simply submitting the ANNOMAC macro:

     %annomac; 

    Note: The ANNOMAC macro must be run before any other Annotate macros are used in a SAS session. You will see a message in the SAS log that indicates that the Annotate macros are now available. The message also shows you how to get help for using the macros.

Annotate Macro Task Summary

The following table summarizes the tasks performed by the Annotate macros.

Table 25.1: Tasks with Annotate Macros

If you want to

Use this macro

assign values of (XLSTT,YLSTT) to (XLAST,YLAST)

%TXT2CNTL;

begin drawing a polygon

%POLY( x, y, color , style, line );

continue drawing a polygon

%POLYCONT( x, y, color );

copy (XLAST,YLAST) to (XLSTT,YLSTT)

%CNTL2TXT;

declare all variables

%DCLANNO;

draw a bar

%BAR( x 1, y 1, x 2, y 2, color, line, style );

draw a circle

%CIRCLE( x, y, size , color );

draw a frame

%FRAME( color, line, size, style );

draw a line from (XLAST,YLAST) to (XLSTT,YLSTT)

%DRAW2TXT( color, line, size );

draw a line from previous point

%DRAW( x, y, color, line, size );

draw a line

%LINE( x 1, y 1, x 2, y 2, color, line, size );

draw a pie slice or arc

%SLICE( x, y, angle, rotate, size, color, style, line );

draw a rectangle

%RECT( x 1, y 1, x 2, y 2, color, line, size );

draw text

%LABEL( x, y, text, color, angle, rotate, size, style, position );

exchange the values of (XLAST,YLAST) and (XLSTT,YLSTT)

%SWAP;

move to a point near a pie slice

%PIEXY( angle, size );

move to a point without drawing

%MOVE( x, y );

put values into a stack

%PUSH;

retrieve values from a stack

%POP;

scale and move input

%SCALET( ptx, pty, x 0, y 0, x 1, y 1, x 0, vy 0, vx 1, vy 1);

scale input

%SCALE( ptx, pty, x 0, y 0, x 1, y 1, x 0, vy 0, vx 1, vy 1);

set the coordinate system for the observation

%SYSTEM( xsys, ysys, hsys );

set when to draw an observation

%SEQUENCE( when );

write a comment to the data set

%COMMENT( text );




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