Remove overlapping X-axis labels on a barchart

1k Views Asked by At

Short of using annotations, I have been unable to find a reasonable way to prevent my x-axis labels from overlapping when using a barchartparm in SAS. From the documentation, they clearly state that barcharts use a discrete axis and the other axis types such as time are not permissible for them. Although conceptually this makes sense it seems like an 'unnecessary' limitation to enforce as it leaves no control over the x-axis labeling as every discrete label will be printed.

Sample data:

data test;
  format rpt_date date9.;
  do rpt_date=date()-90 to date();
    root = round(ranuni(1) *100,1);
    output;
  end;
run;

Define the chart template:

proc template;
  define statgraph giddyup;
    begingraph;
        layout overlay; 
          barchartparm  x=rpt_date y=root ;
        endlayout;
    endgraph;
  end;
run;

Create the chart:

proc sgrender data=test template=giddyup;
run;

Result:

result

I tried to be duct-tape it and create a custom format for the x-axis that would 'blank-out' many of the values, and although the chart was produced, it stacked all the blanks together (??) and also produced a warning.

I've also tried using the alternate x2axisopts and setting the axis to secondary with no luck.

If I used a series chart I would be able to control the axis fine, but in my case the data is much easier to interpret as a barchart. Perhaps they needed to add additional options to the xaxisopts for barcharts.

The most frustrating thing here is that it's something that you can do in excel in 2 seconds, and to me seems like it would be a very common chart in excel, that is not easily reproducible in SAS!

EDIT: I also don't want to use proc gchart .

1

There are 1 best solutions below

0
On BEST ANSWER

Ok now I feel silly. Turns out that histograms will achieve the same result nicely:

histogramparm x=rpt_date y=root ;

Still a valuable question I guess as I spent a lot of time googling for answers and could not find a solution.

result

Good thing I didn't want it horizontal...