Sample 24914: Create candle stick plots
goptions reset=all border;
data stocks;
input date date7. high low close open;
datalines;
01mar99 120 110 115 113
02mar99 118 114 115 115
03mar99 120 112 113 115
04mar99 119 110 111 119
05mar99 115 113 115 115
;
data candles;
length color function style $8;
retain xsys ysys '2' color 'blue' size 1;
set stocks;
if close > open then style='empty'; else style ='solid';
/* Draw the open/close box */
function='move'; xsys='2'; ysys='2'; x=date; y=close; output;
function='poly'; xsys='7'; ysys='2'; x=+1; y=close; output;
function='polycont'; y=open; output;
function='polycont'; x=-1; y=open; output;
function='polycont'; y=close; output;
function='polycont'; x=+.5; y=close; output;
/* Draw high to close and low to open */
if close > open then do;
function='move'; xsys='2'; ysys='2'; x=date; y=close; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=high; output;
function='move'; xsys='2'; ysys='2'; x=date; y=open; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=low; output;
end;
/* Draw high to open and low to close */
if close le open then do;
function='move'; xsys='2'; ysys='2'; x=date; y=open; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=high; output;
function='move'; xsys='2'; ysys='2'; x=date; y=close; output;
function='draw'; xsys='2'; ysys='2'; x=date; y=low; output;
end;
run;
symbol1 i=none v=none r=2;
axis1 minor=none offset=(5,5)pct;
axis2 label=('Price') minor=none;
title1 'Candle Stick Plots';
/* PROC GPLOT is used as a 'holding' area for the annotate, plus, gplot */
/* generates the axes. Had to do an overlay plot so that the vertical */
/* axis had the complete range of the data, ie., high to low. */
proc gplot data=stocks;
plot high*date low*date / overlay haxis=axis1 vaxis=axis2 anno=candles;
format date date5.;
run;
quit;

This example uses the Annotate Facility to generate candle stick plots.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Special Plot types
|
| Date Modified: | 2005-08-31 03:03:13 |
| Date Created: | 2004-11-11 11:07:59 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |