Reputation: 97
I think the plotting engine in SAS is not really straight forward. I hope someone can help me on that:
I want to plot the volumes of 4 different stocks´ orderbooks. But it just draws weird dots. I have the following sample dataset:
Stock AskVolume1 AskVolume2 AskVolume3 BidVolume1 BidVolume2 BidVolume3 AskScaledPrice1 AskScaledPrice2 AskScaledPrice3 BidScaledPrice1 BidScaledPrice2 BidScaledPrice3
StockA 1 2 3 1 2 3 -9.7 -9.8 -9.9 9.7 9.8 9.9
StockB 2 4 6 2 4 6 -9.6 -9.7 -9.9 9.5 9.6 9.8
StockC etc...
The horizontal axis should show the price, with 10 at the midpoint. The volume should be on the vertical axis (the graphs should look like a V in the end, one V shaped graph per stock).
The code I have, that doesnt work is:
goptions reset=all noborder ctext=CX000000 htext=20 pt
colors=(CX0000FF CXFF0000 CX008080 CX00FF00 CXFF00FF CXFFFF00 CX00FFFF CX800000 CX008000
CX800080 CX000080 CX808000 CXFFFFFF CX808080 CXC0C0C0 CX000000);
ods _all_ close; ods listing device=png ;
filename myfile "&DIRECTORY.\output.png";
title1 justify=center color=CX000000 height=14 pt "OrderBook Shapes";
/* set the graphics environment */
goptions reset=global gunit=pct border
ftext=swissb htitle=6 htext=3;
/* set the graphics device */
goptions device=ps300 rotate=landscape ;
/* define titles and footnotes */
title1 'OrderBooks';
/* define symbol characteristics */
symbol1 color=black interpol=join value=dot height=2;
symbol2 color=black interpol=join value=diamond height=3;
/* generate two plots */
proc gplot data=plot2;
plot
BidVolume1*Price1=stock BidVolume2*price2=stock (....etc)
AskVolume1*Price1=stock AskVolume2*price2=stock (....etc)
/ overlay;
run;
Thank you for any input!
Upvotes: 0
Views: 63
Reputation: 9569
The problem is that you are trying to use y*x=z plots with the overlay option. This is not supported, as per the documentation page: http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gplot-plot.htm
OVERLAY is not enabled with plot requests of the form y-variable*x-variable=third-variable.
I suggest you instead concatenate stock and bid/volume number (1-3) into a single categorical variable and then use that as your z-variable, without using the overlay option.
You might also want to look into using proc sgplot instead if your version of SAS supports that, as proc gplot is very old and not as well documented.
Upvotes: 1