BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi

In Proc Gbarline Is there any way to force a line plot to use the same axis (or axis settings) as the bar plots?

I can’t do it manually since I am using a BY variable to produce many charts.

proc gbarline data= test1;
by sektor;
bar aar / discrete sumvar=col1 subgroup=_NAME_;
plot / sumvar=col1;
run;
2 REPLIES 2
GraphGuy
Meteorite | Level 14
I don't think there is a way to guarantee both the left & right side use the same axis scale, without specifying the scale in an axis statement. Which, as you mention isn't really an option when you're using a "by" statement (because each by-group might need a different axis scale).

If you really-really-really want to do it, here's one way I can think of...

Rather than using a 'by statement', get a list of all the unique by-values into a data set, and then loop through that data set and each time through call a macro and pass to it what-would-be the 'by value'. The macro would subset the data (based on the passed-in parameter), and then do some calculations and pick a good axis min/max/by values would be, and hard-code them into an axis statement (each time the macro is called, and then call gbarline. You'd basically be implementing the 'by processing' manually, and also implementing the 'axis auto-scaling' manually ... which would be quite a bit of work.
ArtC
Rhodochrosite | Level 12
Another approach is to calculate the max and min Y values across the two axes within a BY group (MEANS/SUMMARY). and then merge those two values back into the plot data as unplottable points (x axis missing) for both axes.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1155 views
  • 0 likes
  • 3 in conversation