I have implemented a workaround that generates a histogram-like plot.
It works like this:
You first obtain a dataset with bin data from PROC UNIVARIATE
If any bin is equal to zero, you add a small nonzero value (e.g. 1e-9)
You use PROC SGPLOT to plot a STEP line, which will be the outline of your "histogram"
In the same PROC SGPLOT block, you use a BAND statement to fill the area below the outline
You give the y axis a lower limit of 1e-1
The result looks like this, with some minor tweaks it can pass as a histogram:
And here's the macro that does it:
%macro plot_logy_histo(inData=, var=, title=, debug=0);
%local bindat;
/* create dataset with bin contents */
proc univariate data=&inData. noprint;
histogram &var. / vscale=count outhistogram=_DATA_(label=plot_logy_histo bindat) noplot;
run;
%let bindat=&SYSLAST.;
/* add dummy data to zero bins */
data &bindat.;
set &bindat.;
if _count_ eq 0 then _count_=_count_+1e-9;
run;
proc sgplot data=&bindat. noautolegend;
title "&title.";
yaxis logbase=10 type=log min=1e-1 label="Number of Polling Divisions";
xaxis valuesformat=percentn7. label="Percentage";
step x=_midpt_ y=_count_ / lineattrs=(thickness=0) name = "outline";
band x=_midpt_ upper=_count_ lower=1e-9 / outline fill modelname="outline" fillattrs=(color=&ec_burgundy.);
run;
title;
%if &debug. eq 0 %then %do;
proc delete data=&bindat.;
run;
%end;
%mend;
... View more