Hi Community!
I'd like to have the grid at the white spaces between the bars. How can I achieve that?
Here is my code and the result as PDF:
options papersize=(42cm 29.7cm);
ods graphics on / width=40cm height=28cm attrpriority=none;
options nodate nonumber orientation=landscape topmargin="1cm" center;
ods html close;
ods pdf file='Y:\...\Test.pdf';
PROC SGPLOT DATA = dataset;
xaxis display=(noticks) grid;
yaxis values=(0 to 4 by 0.5) offsetmin=0 valueattrs=(size=17);
styleattrs datacolors=(STLG BIGB STYPK LIBGR);
vbar Lab / response=Wert group=Gr groupdisplay=cluster nooutline;
keylegend / noborder autooutline titleattrs=(size=15) valueattrs=(size=15);
run;
ods pdf close;
ods html;
Best regards
Antje
Hi @AntjeWestphal,
You can remove the GRID option from the XAXIS statement and create the new grid lines as reference lines instead (using the grid lines' style):
refline Lab / axis=x discreteoffset=-0.5 lineattrs=GraphGridLines;
refline Lab / axis=x discreteoffset= 0.5 lineattrs=GraphGridLines;
Actually either of the two statements above is sufficient to draw the grid lines between the groups of bars -- plus one to the left of the first group or one to the right of the last group, respectively. (To hide that possibly unwanted additional line, you could draw a white reference line over it.)
Hi @AntjeWestphal,
You can remove the GRID option from the XAXIS statement and create the new grid lines as reference lines instead (using the grid lines' style):
refline Lab / axis=x discreteoffset=-0.5 lineattrs=GraphGridLines;
refline Lab / axis=x discreteoffset= 0.5 lineattrs=GraphGridLines;
Actually either of the two statements above is sufficient to draw the grid lines between the groups of bars -- plus one to the left of the first group or one to the right of the last group, respectively. (To hide that possibly unwanted additional line, you could draw a white reference line over it.)
Dear FreelanceReinhard,
thanks a lot! I tried around a bit and that works perfect:
refline Lab / axis=x discreteoffset=-0.5 lineattrs=(color=darkgrey);
refline Lab / axis=x discreteoffset= 0.5 lineattrs=(color=darkgrey);
refline Lab / axis=x discreteoffset= 0.0 lineattrs=(color=white);
Best regards and a guten Rutsch! 🎉🍀😁
Antje
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.