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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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