/* In this expamle shows how to label part of the data */
/* Using annotate in SAS GPLOT */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Set up the annotate data sets */
data anno;
length function colot $8.;
retain xsys ysys '2' ;
set sasuser.admit;
if weight gt 160 then do;
function='label';
x=weight;
y=height;
color='black';
position='2';
text=trim(left(put(height,6.1)));
output;
end;
run;
title1 'Annotate specific points on a graph';
/* Set up symbols and axises */
symbol1 interpol=none value=dot color=vibg h=1.2;
axis1 label=("Weight in pounds") offset=(2,2)pct;
axis2 label=(a=90 "Height in inches") order=(55 to 80 by 5) minor=(n=4);
proc gplot data=sasuser.admit;
plot height*weight / haxis=axis1 vaxis=axis2 href=160 lhref=20 chref=depk annotate=anno;
/* href draws the verticle line in the plot */
run;
quit;
***********************************************************************************
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Set up the annotate data sets */
data anno2;
length function color $8.;
retain xsys ysys '2' ;
set sasuser.admit;
function='symbol';
size=2;
x=weight;
y=height;
text='dot';
if weight gt 160 then color='depk';
else color='vibg';
output;
run;
title1 'Annotate specific points on a graph with diff color';
/* Set up symbols and axises */
symbol1 interpol=none color=white h=1.2;
axis1 label=("Weight in pounds") offset=(2,2)pct;
axis2 label=(a=90 "Height in inches") order=(55 to 80 by 5) minor=(n=4);
proc gplot data=sasuser.admit;
plot height*weight / haxis=axis1 vaxis=axis2 href=160 lhref=20 chref=depk annotate=anno2;
/* href draws the verticle line in the plot */
run;
quit;
Excellent Code.
ReplyDeleteHelped me in fixing my problem within 5 minutes.
Great Job guys and thanks for sharing it.