BookmarkSubscribeRSS Feed
Obsidian | Level 7

I've got a couple of different barchartparm -templates used by a report. All resulting graphs are horizontal barcharts but some are grouped and some are not.

I need for all the bars in the different graphs in the report to have the same thickness.

I'm working om a macro that sets the height of each graph depending on the data sent to the template at runtime (How many groups, how many category values). I'm having a bit of trouble getting it right though.


Looking for tips/ideas or possibly a detailed paper on how sas manages/divides the space available?

Super User

Since the basic parameter that you would set is BARWIDTH in BARCHARTPARM statement, which

specifies the width of a bar as a ratio of the maximum possible width. If you would be calculating a number of "graph heights"  for different graphs you would be calculating a different BARWIDTH for each size graph, requiring as a minimum the exact number of bars that will appear in each graph and calculating for multiple graphs my get quite tedious to manage. How many different graphs are you talking, with how many bars each?


Personally I find that somewhat distracting, having many graphs of different sizes. I would be strongly tempted to settle on one size or possibly two if at all practical so there are fewer things to try to keep track of.


If the primary concern is the bar thickness you might consider using a VECTOR plot instead with a origin of your axis (vertical or horizontal) which would require adding an xorigin yorigin pair for each bar. That supports either the LINEATTRS with a thickness attribute or the LINETHICKNESSRESPONSE= option that lets you use a variable to control thickness as a specified dimension. You would use ARROWHEADS=False to not display arrows.


If this is for publication you may run into graph size rules to consider first before even going down this path.

Meteorite | Level 14

One way to do this automatically is to use the SGPANEL procedure.  The PANELBY statement has the option - PROPORTIONAL.  This is useful for discrete chart case, and each panel in the graph is sized differently to maintain the same bar width. 


You can also set the ROWS option to output only one row per output graph.  You just have to set up your data  with a classification variable.  Maybe you can leverage this to create your graphs.  Just a thought...


Meteorite | Level 14

Are you using SAS/Graph (gchart), or ODS Graphics (sgplot), or other?


Meteorite | Level 14

If you're using SAS/Graph (proc gchart), then I don't think the solutions posted so far will work for you.



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
  • 5 replies
  • 1 like
  • 4 in conversation