Data visualization with SAS programming

SAS 9.1.3 Proc gplot with annotate

Reply
N/A
Posts: 0

SAS 9.1.3 Proc gplot with annotate

Hi everyone,

How can i fix the overlap of the chart and the annotate in a proc gplot?
Here is the code that i use please see the code below.

proc sql noprint;
create table lineanno as
select * from work.temp
having prc_date=max(prc_date);
quit; run;

data lineanno; set lineanno;
length text $20.;
xsys='2'; ysys='2'; hsys='3'; position='6'; style='"arial/bold"'; color='black';
x=prc_date; y=yield; function='label'; text=' '||trim(left(pass_grade));
run;

data tablanno; set work.temp;
length text $20.;
length function $8.;
xsys='2'; ysys='2'; hsys='3'; position='5'; style='"arial/bold"'; color='black';
function='move'; x=prc_date; y=0; output;
ysys='3';
function='label';
text=trim(left(put(yield,comma4.1)));
if pass_grade eq 'Grade 1' then y=15;
else if pass_grade eq 'Grade 2' then y=11;
else if substr(pass_grade,1,1) eq 'T' then y=7;
output;
run;
data tabllabl;
length text $20.;
length function $8.;
xsys='3'; ysys='3'; hsys='3'; position='6'; style='"arial/bold"'; color='black';
x=2.5;
y=15; text='Grade 1'; output;
y=11; text='Grade 2'; output;
y=7; text='Total G'; output;
run;
data grayline;
xsys='1'; ysys='3'; color='gray';
function='move'; x=0; y=17; output;
function='draw'; x=100; y=17; output;
run;
data tablanno; set tablanno tabllabl grayline;
run;

ODS LISTING CLOSE;
goptions reset=all cback='white' device=activex gunit=pct ctext=black
htitle=6 ftitle="arial/bo" htext=3.25 ftext="arial/bo";


/* ODS HTML path=odsout body="&name..htm" (title="") style=minimal;*/
/*goptions noborder;*/

goptions xpixels=1200 ypixels=350;

symbol1 i=sm v=circle h=1.8 w=1.8 c=blue ;
symbol2 i=sm v=circle h=1.8 w=1.8 c=black ;
symbol3 i=sm v=circle h=1.8 w=1.8 c=green ;

axis1 label=(angle=270 "Grade") order=(0 to 100 by 10) minor=none offset=(0,0) major=none;
axis2 label=none order=('01OCT2009'd to '01NOV2009'd by 1) minor=none offset=(0,0) ;

title1 "DET";

proc gplot data=work.temp anno=tablanno;
plot yield*prc_date=pass_grade /
cframe=ligr
vaxis=axis1
haxis=axis2
/* autovref */
/* cvref=black */
/* nolegend*/
/* cvref=black vref=32*/
anno=lineanno
autovref
/* legend=legend1*/
noframe
;
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

Thanks,,,
SAS Employee
Posts: 967

Re: SAS 9.1.3 Proc gplot with annotate

Hard to tell without the work.temp data to try the graph, but ...

I assume since you're using xsys/ysys=2 that you're annotating the table inside the graph axes area(?), and you don't want the annotated text to overlap with the gplot markers(?)

In axis statements, you can use the 'offset' option to add whitespace within the axes, to guarantee there will be space inside the axes that doesn't contain gplot lines/markers, and annotate the table there.

Or, I would recommend annotating the table outside the gplot axes, along the side of the graph (you'll have to use a different xsys/ysys) - you can use a fake/blank title, angled on the side of the graph, to make room for the table, such as ...

title2 angle=90 height=10pct " ";
(or use -90 for the other side)

[Note that you can't use fake blank titles like this with dev=java and activex, only with the traditional devices like gif, png, etc.]
Ask a Question
Discussion stats
  • 1 reply
  • 314 views
  • 0 likes
  • 2 in conversation