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?

 

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 829 views
  • 1 like
  • 4 in conversation