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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.