Showing posts with label proc gplot. Show all posts
Showing posts with label proc gplot. Show all posts
Thursday, April 28, 2011
Monday, March 21, 2011
Label overlay lines seperately by annotation
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt;
/* Create input data set, PRODCOST */
data prodcost (drop=tcprev tfc tvc tc);
retain tcprev 0;
input quan tfc tvc;
tc=tfc+tvc;
afc=tfc/quan; /* average fixed cost */
avc=tvc/quan; /* average variable cost */
atc=tc/quan; /* average total cost */
mc=tc-tcprev; /* marginal cost */
tcprev=tc;
datalines;
1 10 05
2 10 08
3 10 10
4 10 11
5 10 13
6 10 16
7 10 20
8 10 25
9 10 31
10 10 38
11 10 46
;
run;
data anno;
set prodcost end=last;
function='label';
retain xsys ysys '2' hsys '9' position '6';
size=3;
if last then do;
x=quan;
y=afc; color='depk'; text='AFC'; output;
y=avc; color='vibg'; text='AVC'; output;
y=atc; color='mob'; text='ATC'; output;
y=mc; color='black'; text='MC'; output;
end;
run;
/* Create axis definitions */
axis1 minor=none offset=(1,8)
label=('Thousands of Units');
axis2 order=(0 to 16 by 4) minor=(number=3 color=red height=.3 width=5) offset=(0,0)
label=('Dollar Cost' justify=left '(in hundreds)');
symbol1 interpol=spline color=depk width=1;
symbol2 interpol=spline color=vibg width=1;
symbol3 interpol=spline color=mob width=1;
symbol4 interpol=spline color=black width=1;
title1 'Projected cost of production';
proc gplot data=prodcost;
plot (afc avc atc mc)*quan / overlay frame vaxis=axis2 haxis=axis1 annotate=anno;
run;
quit;
/* spline用来连接data成为一条曲线 */
/* overlay用来把图片叠加 */
/* minor用来设置小的刻度(major用来设置大的刻度) */
/* offset用来在坐标轴上起始/末尾位置留下空白 */
Labels:
annotate,
proc gplot
Sunday, March 20, 2011
Annotate specific points in a graph
/* 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;
Labels:
annotate,
proc gplot
Subscribe to:
Posts (Atom)


