Here in the US, we recently had a new Supreme Court Justice appointed. This is a very important position, and judges usually serve until they retire or die. My buddy Rick gave me a heads-up that there was a table of all the past & present justices on Wikipedia, and [...]

The post Timeline of US Supreme Court Justices appeared first on SAS Learning Post.

Have you been using the SAS/Graph Gmap procedure to plot your data on maps for years, but never knew you could add roads to your maps?!? Follow along in this blog post, and I'll teach you how... But before we get started, here's a picture of a nice aerial view [...]

It's easy to plot events that happened at a certain time, but what about events that extended over a range of dates, such as recessions? ... This blog post teaches you a nice trick to use for that! Let's say you have a plot of the labor force participation rate […]

Avast Mateys!  Did you know that International Talk Like a Pirate Day is coming up?!? (September 19) Here's the official website, if you'd like more info. And what better way to get into the spirit of things than to use SAS/GRAPH to plot some real pirate data - Arrrr!!! Here's [...]

/* 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用来在坐标轴上起始/末尾位置留下空白 */

/* 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' ;
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);

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' ;
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);