Just for fun: an other way to do it using Gchart proc format; value ColorM 0 - < 10 = white 10 - < 20 = yellow 20 - < 30 = lightgreen Other = lightblue ; run; data temp; length Mean_Color $12; input P Mean; Mean_Color = put(mean,ColorM.); datalines; 1 41 2 29 3 24 4 23 5 20 6 19 7 19 8 18 9 18 10 16 11 15 12 13 13 7 14 6 ; run; goptions device=png; goptions noborder; ODS LISTING CLOSE; ODS HTML path="/home/hgelders/examples" body="Chart_conditional_coloring..htm" ; goptions gunit=pct htitle=4 ftitle="albany amt/bold" htext=2.5 ftext="albany amt/bold"; goptions ctext=gray33; axis1 label=none value=(height=2); axis2 label=('MEAN') order=(0 to 45 by 5) minor=(number=1) offset=(0, 0); data _Null_; set temp; by p notsorted; if first.p then call execute(cats('pattern',_N_,'09'x,'color=',Mean_Color,';')); run; title1 ls=1.5 "Gchart with conditional coloring"; proc gchart data=my_data; hbar p / discrete type=sum sumvar=mean nostats maxis=axis1 raxis=axis2 subgroup=p patternid=subgroup width=2.2 gspace=0.2 autoref clipref cref=graycc coutline=black nolegend ; run; quit; ODS HTML CLOSE; ODS LISTING;
... View more