BookmarkSubscribeRSS Feed
Calcite | Level 5


I am trying to show a bar chart and I want to show negative values as red and positive values as green. How do i do that in bar chart? Is it possible using proc glpot. I have to use a bar chart only. It is a continous variable.

Also, how do I change the font size of the axis tickmarks, not the axis label which I know can be changed using xaxisopts=(labelattrs=pts).

Also, how do I make the position of the barlabel appear in the middle or at the bottom of a bar, instead of the default top position of the bar?

I have a template and i invoke that template in proc sgrender. Can I define a style statement along with define statgraph? How do I use both in the proc sgrender?

PLease help.

Super User

Please post what you have so far, including sample data so we can replicate your issue and not start from scratch. Additionally, include a picture of what you want as a final result.


Have you looked at SGPLOT so far?

Calcite | Level 5

You will have to convert the sample excel file into sas dataset and run it though this program.


Below is the code:



proc template;

define statgraph mean_chart;



layout overlay/ yaxisopts=(label="%" linearopts=(viewmin=-.10 viewmax=.10))

xaxisopts=(label="Year and Month" );


barchart x=yyyymm y=delta/ dataskin=sheen fillattrs=(color=green) stat=pct barwidth=.50

primary=true name="average" barlabelformat=percent10.1 barlabel=true barlabelattrs=(size=7pt );

bandplot x=yyyymm limitlower=-.02 limitupper=.02 /

legendlabel="95% CLI" name="band1" display=(fill) fillattrs=(color=GraphData4:color)

datatransparency=.7 fillattrs=GraphError



referenceline y=-.02 /curvelabel=eval(putn(mean(&lcl_m.),'percent10.2')) lineattrs=(color=red pattern=dot) name="lcl_m" legendlabel="-2%";

referenceline y=+.02 /curvelabel=eval(putn(mean(&ucl_m.),'percent10.2')) lineattrs=(color=blue pattern=dot) name="ucl_m" legendlabel="+2%";

discretelegend "lcl_m" "ucl_m" ;





proc sgrender data=data template=mean_chart;





Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2 in conversation