BookmarkSubscribeRSS Feed
andypandy_swe
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?

5 REPLIES 5
ballardw
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.

Jay54
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...

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=grstatproc&docsetTarget=n...

 

GraphGuy
Meteorite | Level 14

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

 

andypandy_swe
Obsidian | Level 7

SAS/Graph

GraphGuy
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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1252 views
  • 1 like
  • 4 in conversation