BookmarkSubscribeRSS Feed
RandoDando
Pyrite | Level 9

Is there a way to specify a fill color for the bars in the histogram in the UNIVARIATE procedure conditionally?  For instance, if the value of the variable is < 5 then Red, >5 and < 15 then Yellow, etc.. ?

2 REPLIES 2
Rick_SAS
SAS Super FREQ

No, but you can overlay the categories in the background by using a block plot. Two methods are shown in the article "Overlay categories on a histogram."

 

If you really want the bars themselves colored, you can use a bar chart and make a few modifications so it looks like a histogram. Details at "Histogram with Gradient Color."

RandoDando
Pyrite | Level 9

Here is the code I am using, in case this requires another procedure.  I need the bins to be based on endpoints, and by 1.   

 

ods graphics on;
proc univariate data=DATA  ;
var values;
histogram values/endpoints=(0 to 25 by 1) vscale=count vaxis=(0 to 500 by 100) odstitle="my histogram"
vaxislabel="Count" href=(1 10 25) ;
where values < 25;
run;
ods graphics off;

 

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1085 views
  • 0 likes
  • 2 in conversation