Download presentation

Presentation is loading. Please wait.

Published byDevin Fickett Modified over 2 years ago

1
Controlling SAS Graphics using ANNOTATE Datasets Elizabeth Campagna University of Colorado Denver Colorado Health Outcomes Program Colorado Day – Denver SAS Users Group, September 25 2008

2
Outline Why use ANNOTATE How to use an ANNOTATE dataset What is an ANNOTATE dataset Examples References ANNOTATE Custom SAS Graphics Built-In SAS Graphics

3
Why? Enhancement and modification of graphical features - flexibility to add any drawing object or text, in any format or color, to any place on your graphical output –Position text labels in a graph –Create custom legends –Draw lines between points –Add symbols at specific locations

4
How? Create an ANNOTATE dataset Execute the ANNOTATE commands by including the following option in your SAS/GRAPH code SAS/GRAPH interprets and executes the drawing commands along with the graph and creates output that has both included PROC GPLOT data=apple / ANNOTATE= ; PLOT color*state; RUN;

5
What? Ordinary SAS dataset Each observation is a drawing command defined by the values placed in each of the specific variables. Variables are constricted in values/attributes they can have Variables in an ANNOTATE dataset ALL information What is to be done? FUNCTION How is it to be done? COLOR, SIZE, STYLE, POSITION Where is it to be done? X, Y, XSYS, YSYS

6
What? lowupgrpgrplabelsxyposition 2.192.6231Adjusted+Hospital Effect2.3971.00 2.192.6231Adjusted+Hospital Effect2.1900.95 2.192.6231Adjusted+Hospital Effect2.1901.05 2.192.6231Adjusted+Hospital Effect3.00011.005 functioncolortextstylexsysysyssizelinemid symbolblackdotnone221.0012.397 MOVEblackdotnone221.0012.397 DRAWblackdotnone221.0012.397 labelblackIncreased Likelihood'Arial'231.7512.397... FUNCTION variable tells SAS what to do, the other variables all modify, specify, or locate the function.

7
FUNCTION (what) LABELdraws text MOVEmoves to a specific point DRAWdraws a line from the current position to a specified position POLYspecifies the starting point of a polygon POLYCONTcontinues drawing the polygon BARdraws a rectangle from the current position to a specified position SYMBOLdraws a symbol. PIEdraws a pie slice, circle or arc. MOVEmove to the new x,y coordinates

8
Attributes (how) ANGLEangle of text label or starting angle of a pie slice CBORDERcolored border around text or symbol CBOXcolored box behind text or symbol COLORcolor of a graphics primitive LINEline type to use in drawing or special control over pies and bars POSITIONplacement and alignment for text strings ROTATE angle at which to place individual characters in a text string or the delta angle (sweep) of a pie slice SIZE size of an aspect of a graphics primitive; depends on FUNCTION variable (for TEXT, height of characters; for PIE, pie slice radius; for DRAW, line thickness; and so on) STYLE font or pattern for a graphics element, depends on the FUNCTION variable TEXTtext to use in a label, symbol, or comment Attributes are RETAINED between functions unless re-defined

9
Dimensions (where) X The numeric horizontal coordinate. Y The numeric vertical coordinate. Z For three-dimensional graphs, specifies the coordinate for the 3rd dimension. XSYS The coordinate system for the X variable. YSYS The coordinate system for the Y variable. ZSYS The coordinate system for the Z variable (for three-dimensional graphs).

10
Dimensions (where) Example: XSYS=‘1’; YSYS=‘A’;

11
ANNOTATE MACROS ANNOTATE macros within a SAS DATA step simplify the process of creating ANNOTATE observations. Specify a function and assign variable values (attributes) in one step You can mix assignment statements and macro calls in the same DATA step. Execute: “%annomac;” to make ANNOTATE macros available %LINE(x1, y1, x2, y2, color, line, size);draw a line %BAR(x1, y1, x2, y2, color, line, style);draw a bar %CIRCLE(x, y, size, color);draw a circle %DRAW(x, y, color, line, size);draw a line from previous point %RECT(x 1,y 1,x 2,y 2, color, line, size);draw a rectangle %LABEL(x, y, text, color, angle, rotate, size, style, position); draw text %MOVE(x, y);move to a point without drawing

12
Example How to draw lines, place symbols, & place text Changing attributes Illustrate the use of various coordinate systems Use of ANNOTATE macros midlowupgrpgrplabels 2.3972.192.6231Adjusted+Hospital Effect 2.782.5433.0382Adjusted 4.4514.064.8793Unadjusted

13
Goal

14
SAS Code - ANNOTATE %annomac; data anno; length function color style $8 text $40; xsys='2'; ysys='2'; size=1; line=1; color='black'; set test; * plot Odds Ratios; function='symbol'; style='none' ; text='dot'; x=mid; y=grp; output; * add horizontal lines representing OR CI; function='move'; x=low; y=grp; output; function='draw'; x=up; y=grp; output; * add vertical lines at end of CI; %LINE (low, grp-0.05, low, grp+0.05, black, 1, 1); %LINE (up, grp-0.05, up, grp+0.05, black, 1, 1); * labels; function='label'; style="'Arial'"; size=1.5; x=low; y=grp; position="3"; text=grplabels; output; * use graphics output area for vertical positioning to set x-axis labels below data area; ysys='3'; position="5"; function='label'; size=1.75; x=0.3; y=11; text="Decreased Likelihood"; output; function='label'; x=3; text="Increased Likelihood"; output; run;

15
* plot Odds Ratios; function='symbol'; style='none' ; text='dot'; x=mid; y=grp; output;

16
* add horizontal lines representing OR CI; function='move'; x=low; y=grp; output; function='draw'; x=up; y=grp; output;

17
* add vertical lines at end of CI; %LINE (low, grp-0.05, low, grp+0.05, black, 1, 1); %LINE (up, grp-0.05, up, grp+0.05, black, 1, 1);

18
function='label'; style="'Arial'"; size=1.5; x=low; y=grp; position="3"; text=grplabels; output;

19
* use graphics output area for vertical positioning to set x-axis labels below data area; ysys='3'; position="5"; function='label'; size=1.75; x=0.3; y=11; text="Decreased Likelihood"; output; function='label'; x=3; text="Increased Likelihood"; output;

20
SAS Code – Proc GPLOT goptions reset=all; goptions cback=white ctext=black ftitle='Arial' ftext="Arial" fby='Arial' htitle=2 htext=12 PT gsfname=plots device=gif xmax=6 IN ymax=4 IN; axis1 logbase=10 logstyle=expand order=(0.1 1 10) label=(font='Arial' height=12 PT justify=center ''); axis2 order=(0 to 4 by 1) /* change max axis value as needed (# grps + 1) */ color=white; symbol1 i=none; title 'Odds Ratios w/95% CI'; footnote 'Denver SAS Users Group Colorado Day 2008'; filename plots "H:\misc\DSUG\2008\plot1.gif"; proc gplot data=test; plot grp*up / anno=anno haxis=axis1 vaxis=axis2 href=1 noframe; run; quit; title; footnote;

21
End Result

22
References Introduction to SAS/Graph Michael Friendly Statistical Consulting Service http://www.psych.yorku.ca/lab/sas/sganno.htm SUGI 31, Paper 085-31 Improving Your Graphics Using SAS/GRAPH® ANNOTATE Facility David Mink, Ovation Research Group, San Francisco, CA David J. Pasta, Ovation Research Group, San Francisco, CA http://www2.sas.com/proceedings/sugi31/085-31.pdf Data Driven Annotations: An Introduction to SAS/GRAPH’s® ANNOTATE Facility Arthur L. Carpenter California Occidental Consultants http://www.caloxy.com/papers/67-HW03.pdf http://support.sas.com/onlinedoc/913/docMainpage.jsp SAS OnlineDoc 9.1.3 SAS/GRAPH Reference > The ANNOTATE Facility http://support.sas.com/onlinedoc/913/docMainpage.jsp

Similar presentations

OK

EXCEL CHARTS. CHARTS Charts provide a way of presenting and comparing data in graphical format. Embedded charts or chart sheets Embedded charts are objects.

EXCEL CHARTS. CHARTS Charts provide a way of presenting and comparing data in graphical format. Embedded charts or chart sheets Embedded charts are objects.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Doc convert to ppt online form Cardiopulmonary anatomy and physiology ppt on cells Ppt on precautions of tsunami warning Ppt on indian retail industry Ppt on relations and functions for class 11th result Ppt on effect of global warming on weather oregon Ppt on economic order quantity Ppt on self development of people Ppt on human resources planning Ppt on world sports day