Hello everyone,
I don't know how to change the color only for one bar (for example just for desks) and keep the same color for all the other ones? Could you please help me ? Thank you very much
data error; input Product $ Revenue Upper Lower; datalines; Desks 2000 2200 1800 Chairs 1500 1700 1300 Lamps 1200 1100 1300 ; run; proc template; define statgraph errorbars; begingraph; entrytitle 'Product Revenue'; layout overlay / yaxisopts=(offsetmin=0) xaxisopts=(display=(ticks tickvalues line)); barchart x=product y=revenue; scatterplot x=product y=revenue / yerrorupper=upper yerrorlower=lower markerattrs=(size=0); endlayout; endgraph; end; run; ods listing; ods graphics / reset width=5in height=3in imagename='Error'; proc sgrender data=error template=errorbars; run;
Well, the two things jump to mind:
- Use a proc template step to define a styles for the graph, and set the colors for group 1 to be one color, then the other groups to the same color.
- Use two separate graph statements, one barchart statement for the first group setting the color, then another barchart statement for the rest of the data, setting the color there.
Well, the two things jump to mind:
- Use a proc template step to define a styles for the graph, and set the colors for group 1 to be one color, then the other groups to the same color.
- Use two separate graph statements, one barchart statement for the first group setting the color, then another barchart statement for the rest of the data, setting the color there.
Hey RW9,
Thank you very very muuuuuuuuuuuuuuch, it worked !!!!!
Add a group variable that has one value for the "desks" and another for everything else and use the GROUP option on the scatterplot statement to use that variable to display different color (and/or marker)
Thanks ballardw 😉
Another approach to consider is using a discrete attrmap and setting the group variable on the barchart to be the same as the category variable. In the attrmap, set the one category value to the desired color and the other values to another color. The benefit of this approach is that it will work regardless of data order.
Hope this helps!
Dan
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: