Search code examples
sas

Display only one bar produced by a bar chart


Is there a way to only show one of the bars produced by sgplot vbar? For example,

proc sgplot data=sashelp.birthwgt;
vbar married / stat=percent;
run;

returns this plot:

enter image description here

but I want this (photoshopped):

enter image description here


Solution

  • Use the xaxis statement values= option.

    data have;
      do id = 1 to 100;
        if id < 35 then married='Yes'; else married = 'No';
        output;
      end;
    run;
    
    proc sgplot data=have;
      vbar married / stat=percent;
      xaxis values=('Yes');              * <---------------;
    run;
    

    enter image description here