BookmarkSubscribeRSS Feed
geetaparekh
Calcite | Level 5

Hi,

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.

2 REPLIES 2
Reeza
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?

geetaparekh
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;

begingraph;

 

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" ;

 

endlayout;

endgraph;

end;

proc sgrender data=data template=mean_chart;

run;

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

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