libname R 'C:\'; %let gpath='C:\'; proc template; define style Styles.R; parent = styles.listing; style color_list from color_list "Abstract colors used in graph styles" / 'bgA' = cxffffff; class GraphColors "Abstract colors used in graph styles" / 'gwalls' =cxE5E5E5 'glegend'=cxE5E5E5 'ggrid' =cxFFFFFF ; class GraphWalls / linethickness = 1px linestyle = 1 frameborder = on contrastcolor = GraphColors('gwalls') backgroundcolor = GraphColors('gwalls') color = GraphColors('gwalls'); class GraphGridLines / displayopts = "on" linethickness = 1px linestyle = 1 contrastcolor = GraphColors('ggrid') color = GraphColors('ggrid'); class GraphAxisLines / tickdisplay = "outside" linethickness = 1px linestyle = 1 contrastcolor = GraphColors('gaxis'); class GraphBox / capstyle = "serif" connect = "mean" displayopts = "fill median mean outliers"; end; run; /*--Macro by Perry Watts--*/ %macro RGBHex(rr,gg,bb); %sysfunc(compress(CX%sysfunc(putn(&rr,hex2.)) %sysfunc(putn(&gg,hex2.)) %sysfunc(putn(&bb,hex2.)))) %mend RGBHex; ods html close; ods listing style=styles.R gpath=&gpath image_dpi=100; /*--Grouped Scatter Plot--*/ ods graphics / reset noborder width=5in height=3in imagename='SAS_Cars_Scatter'; proc sgplot data=sashelp.cars; styleattrs datacontrastcolors=(%rgbhex(248,118,109) %rgbhex(0, 186, 56) %rgbhex(97, 156, 255)); scatter x=horsepower y=mpg_city / group=origin markerattrs=(symbol=diamondfilled); xaxis grid display=(noline); yaxis grid display=(noline); keylegend / title='Origin' position=right across=1 noborder; run; /*--Diamonds GTL Scatter Gradient--*/ proc template; define statgraph diamonds; begingraph; layout overlay / xaxisopts=(linearopts=(minorticks=true minortickcount=1 minorgrid=true minorgridattrs=(color=cxF0F0F0)) display=(ticks tickvalues label)) yaxisopts=(linearopts=(minorticks=true minortickcount=1 minorgrid=true minorgridattrs=(color=cxF0F0F0)) display=(ticks tickvalues label)); scatterplot x=carat y=price / datatransparency=0 markerattrs=(symbol=circlefilled size=3) markercolorgradient=price name='a' colormodel=(%rgbhex(19,43,67) %rgbhex(82,169,237)); continuouslegend 'a' / halign=right; endlayout; endgraph; end; run; /*--Gradient Scatter Plot--*/ ods graphics / reset noborder width=5in height=3in noborder antialiasmax=54000 imagename='Diamonds_GTL_Gradient'; proc sgrender data=r.diamonds template=diamonds; run; title; footnote; /*--Box Plot of DSmall--*/ ods graphics / reset noborder width=5in height=3in noborder imagename='DSmall_SG_VBox'; proc sgplot data=r.dsmall; vbox price / category=cut fillattrs=(color=white) boxwidth=0.7; xaxis values=('Fair' 'Good' 'Very Good' 'Premium' 'Ideal') grid display=(noline); yaxis grid display=(noline); run; /*--Heart Overlay Histograms--*/ ods graphics / reset noborder width=5in height=3in noborder attrpriority=color imagename='Hist_Overlay_SAS'; proc sgplot data=sashelp.heart; histogram diastolic / binstart=35 binwidth=10 transparency=0.5 fillattrs=(color=%rgbhex(248,118,109)) scale=count; histogram systolic / binstart=35 binwidth=10 transparency=0.5 fillattrs=(color=%rgbhex(0,191,196)) scale=count; xaxis grid display=(noline nolabel); yaxis grid display=(noline); keylegend / position=right noborder noopaque; run;