%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi;; /*--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; ods html; proc print data=stock(obs=8) noobs; var date high low open close gain v1 v2 lowcap highcap; run; ods html close; data attrmap; length value $4 fillcolor $10; id='Color'; value='Up'; fillcolor='LightGreen'; output; id='Color'; value='Down'; fillcolor='LightRed'; output; id='Mono'; value='Up'; fillcolor='white'; output; id='Mono'; value='Down'; fillcolor='gray'; output; run; /*--Colored CandleStick--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='CandleStick'; title 'Monthly Stock Price'; proc sgplot data=stock dattrmap=attrmap; highlow x=date low=low high=high / type=line; highlow x=date low=v1 high=v2 / type=bar group=gain lineattrs=(color=black) name='a' attrid=Color; yaxis label='Price' grid; xaxis display=(nolabel); keylegend 'a' / location=inside position=bottom; run; /*--Traditional CandleStick--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='CandleStickGray'; title 'Monthly Stock Price'; proc sgplot data=stock dattrmap=attrmap; highlow x=date low=low high=high / type=line; highlow x=date low=v1 high=v2 / type=bar group=gain lineattrs=(color=black) name='a' attrid=Mono; yaxis label='Price' grid; xaxis display=(nolabel); keylegend 'a' / location=inside position=bottom; run; /*--Colored CandleStick with Caps--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='CandleStickCap'; title 'Monthly Stock Price'; proc sgplot data=stock dattrmap=attrmap; highlow x=date low=low high=high / type=line; highlow x=date low=v1 high=v2 / type=bar group=gain lineattrs=(color=black) name='a' attrid=Color lowcap=lowcap highcap=highcap; yaxis label='Price' grid; xaxis display=(nolabel); keylegend 'a' / location=inside position=bottom; run; /*--Traditional CandleStick with Caps--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='CandleStickGrayCap'; title 'Monthly Stock Price'; proc sgplot data=stock dattrmap=attrmap; highlow x=date low=low high=high / type=line; highlow x=date low=v1 high=v2 / type=bar group=gain lineattrs=(color=black) name='a' attrid=Mono lowcap=lowcap highcap=highcap; yaxis label='Price' grid; xaxis display=(nolabel); keylegend 'a' / location=inside position=bottom; run; /*--Colored CandleStick with Caps Icon--*/ ods listing image_dpi=100; ods graphics / reset attrpriority=color width=2.7in height=1.8in imagename='CandleStickIcon'; title; proc sgplot data=stock(where=(date > '01Jan2005'd)) dattrmap=attrmap; highlow x=date low=low high=high / type=line; highlow x=date low=v1 high=v2 / type=bar group=gain barwidth=1 lineattrs=(color=black) name='a' attrid=Color lowcap=lowcap highcap=highcap; yaxis label='Price' grid display=(nolabel); xaxis display=(nolabel); keylegend 'a' / location=inside position=topright; run;