Hi,
As fas as I could read in the SAS online doc, it is currently not possible to display zero frequencies in a bar char.
I could manage to add it using the values options of xaxis statement but the value 0 is not displayed with datalabel and the bar at value zero is also not displayed.
Are you aware of any other solution I could consider (format?, other option? vbarbasic?, vbarparm?)
data cnt;
gender='M'; freq=9; output;
gender='F'; freq=8; output;
gender='X'; freq=0; output;
run;
proc print data=cnt;
run;
ods graphics / width=15cm height=10cm noborder;
proc sgplot data=cnt noborder;
vbar gender / freq=freq missing displaybaseline=off datalabel;
xaxis values=('M' 'F' 'X')
display = (noline);
run;
ods graphics off;
Here is how I would do it. Example using SASHELP.CLASS data set
proc format;
value $ sexfmt "F"="Female"
"M"="Male"
"X"="X";
run;
proc summary data=sashelp.class nway completetypes;
class sex / preloadfmt order=formated missing;
format sex $sexfmt.;
output out=counts;
run;
proc sgplot data=counts;
vbarparm category=sex response=_FREQ_ / nozerobars;
run;
Here is how I would do it. Example using SASHELP.CLASS data set
proc format;
value $ sexfmt "F"="Female"
"M"="Male"
"X"="X";
run;
proc summary data=sashelp.class nway completetypes;
class sex / preloadfmt order=formated missing;
format sex $sexfmt.;
output out=counts;
run;
proc sgplot data=counts;
vbarparm category=sex response=_FREQ_ / nozerobars;
run;
Thank you 🙂
Anytime 🙂
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.