Sample 24876: Stacked bar chart representing on/off states of a constant
/* Set graphics options */
goptions reset=all border;
/* Create input data set, A */
data a;
input machine type $ time;
datalines;
1 running 10
1 idle 1
1 running 4
1 idle 2
1 running 7
2 running 4
2 idle 2
2 running 6
2 idle 1
2 running 1
2 idle 3
2 running 2
2 idle 2
2 running 1
2 idle 2
;
proc sort data=a out=a;
by machine;
run;
/* Create the annotate data set, ANNO */
data anno;
length function color $8;
/* The BAR function is used to draw a fillable */
/* rectangle whose lower-left corner is defined*/
/* by the internal variables (XLAST,YLAST) and */
/* whose upper-right corner is defined by the */
/* (X,Y) variable pair. */
retain function 'bar' xsys '2' style 'solid' time2 0;
set a;
by machine;
if first.machine then time2=0;
function='move'; x=machine; xsys='2'; ysys='2'; y=time2; output;
function='move'; xsys='9'; x=-3; y=time2; output;
if type = 'running' then color='green';
if type = 'idle' then color='red';
function='bar'; xsys='9'; x=+6; ysys='2'; y=time2+time; output;
time2=time2+time;
y=0;
run;
proc print data=anno;
run;
/* Create the axis definitions */
axis1 order=(0 to 3 by 1) value=('' 'M1' 'M2' '')
major=(h=.001) minor=none;
axis2 order=(0 to 24 by 6) offset=(0) minor=none;
/* Assign symbol characteristics */
symbol1 i=none v=none;
/* Add the title */
title1 f=zapfb c=green 'ACTIVE' c=black ' and ' c=red 'IDLE';
/* Produce the plot */
proc gplot data=a;
plot time*machine / anno=anno haxis=axis1 vaxis=axis2 frame;
run;
quit;

Stacked bar chart representing on/off states of a constant, such as the running/idle times of a computer. The Annotate facility is used to draw the bars of the chart.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Special Charts
|
| Date Modified: | 2005-08-24 16:06:27 |
| Date Created: | 2004-11-11 11:07:54 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |