Please help with color in histogram

A few days ago I was asked how to change the fill color of the histogram bars to light green when using Proc UNIVARIATE. The person did try to use the cfill option, however this does not work with ods graphics. They also created a template and specified the color green. However they wanted light green. In the end they produced this graph.

image001

The above graph is a really good attempt actually and they decided to contact me because they discovered the SAS 9.2 Graphics Course on line which I created and gave a few years ago.

I knew exactly how to change the color of the histogram bars to light green and this is because of the knowledge I gained on specifying hexadecimal colors and on modifying style templates which I mainly learned from the book Statistical Graphics in SAS: An Introduction to the Graph Template Language and the Statistical Graphics Procedures by Warren Kuhfeld.

Without further ado, below is the image I created.

image1

 

I used the website http://www.colorpicker.com to help decide on the shade of green to select, and modified the Statistical template with the required change. Please see the code below that was used.

data Trans;
input Thick @@;
label Thick = ‘Plating Thickness (mils)’;
datalines;
3.468 3.428 3.509 3.516 3.461 3.492 3.478 3.556 3.482 3.512
3.490 3.467 3.498 3.519 3.504 3.469 3.497 3.495 3.518 3.523
3.458 3.478 3.443 3.500 3.449 3.525 3.461 3.489 3.514 3.470
3.561 3.506 3.444 3.479 3.524 3.531 3.501 3.495 3.443 3.458
3.481 3.497 3.461 3.513 3.528 3.496 3.533 3.450 3.516 3.476
3.512 3.550 3.441 3.541 3.569 3.531 3.468 3.564 3.522 3.520
3.505 3.523 3.475 3.470 3.457 3.536 3.528 3.477 3.536 3.491
3.510 3.461 3.431 3.502 3.491 3.506 3.439 3.513 3.496 3.539
3.469 3.481 3.515 3.535 3.460 3.575 3.488 3.515 3.484 3.482
3.517 3.483 3.467 3.467 3.502 3.471 3.516 3.474 3.500 3.466
;
run;
proc template ;
define style Styles.newstyle;
parent = Styles.statistical;
style GraphDataDefault from GraphDataDefault /Color = cx00FF00;
/* This color specifies light green and codes can be found from the website http://www.colorpicker.com */
end;
run;

ods graphics on / reset = all imagename =”image” width = 3in height = 2in ;
ods html style = styles.default;
ods listing style = styles.newstyle gpath = “C:\Users\Kriss\Documents\Graphs” dpi = 300;
goptions reset=all border;
title ‘Analysis of Plating Thickness’;
proc univariate data=Trans noprint;
histogram Thick;
run;

Afterwards, I was asked how to make the background of the graph yellow, and this is done by adding in this code to the template:

style GraphBackground from GraphBackground /color = yellow;

Voila!

image21