Hi Team,
Do you know any sample sgprot codes draw candle stick charts with volume information?
I found some only for prices in candle stick but don't see codes including volume information at the bottom of the chart.
sashelp.stocks as the example.
Thank you,
There is an example here: http://support.sas.com/kb/35/040.html
that starts with the SASHELP.STOCKS data set that may get you started.
You don't explain in your PDF what the difference may be between the red and green elements so can't make any suggestions.
Rough idea is here:
/*--Extract one stock, set group and add caps based on Open > Close--*/
data stock;
length Gain $4 lowcap highcap $12;
set sashelp.stocks(where=(stock='IBM' and date > '01Jan2003'd));
if open < close then do;
gain='Up';
v1=open; v2=close;
lowcap='';
highcap='FilledArrow';
end;
else do;
gain='Down';
v1=close; v2=open;
lowcap='FilledArrow';
highcap='';
end;
run;
proc template;
define statgraph needleVolume;
begingraph / collation=binary;
EntryTitle "Monthly Stock Price" /;
layout gridded / columns=1 rows=2 rowgutter=5 columngutter=5;
layout overlay / xaxisopts=(display=(ticks tickvalues line) type=time)
y2axisopts=(labelFitPolicy=Split) yaxisopts=(Label="Price"
labelFitPolicy=Split type=linear griddisplay=on)
y2axisopts=(labelFitPolicy=Split);
HighLowPlot X=Date High=High Low=Low / primary=true LegendLabel="HighLow"
NAME="HIGHLOW";
HighLowPlot X=Date High=v2 Low=v1 / type=bar Group=COLOR_GAIN
OutLineAttrs=(Color=CX000000) LegendLabel="HighLow" NAME="a";
DiscreteLegend "a" / Location=Inside valign=bottom;
endlayout;
layout overlay / yaxisopts=(labelFitPolicy=Split)
y2axisopts=(labelFitPolicy=Split);
NeedlePlot X=Date Y=Volume / primary=true LegendLabel="Volume" NAME="NEEDLE";
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender template=needleVolume data=stock;
run;
@k_shide wrote:
Hi Team,
Do you know any sample sgprot codes draw candle stick charts with volume information?
I found some only for prices in candle stick but don't see codes including volume information at the bottom of the chart.sashelp.stocks as the example.
Thank you,
Here's the reference to the SGTEMPLATE documentation
Thank you very much. I understand the idea.
Actually R provides quite powerful charting procedure as attached pdf file and if SAS also could do that's great but seems to require more complicated template creation right?
There is an example here: http://support.sas.com/kb/35/040.html
that starts with the SASHELP.STOCKS data set that may get you started.
You don't explain in your PDF what the difference may be between the red and green elements so can't make any suggestions.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.