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.. ?
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."
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.