Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- Calculate the necessary height of a graph

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 02-16-2021 03:39 AM
(456 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

SAS/Graph

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

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.