Why doesn't this produce any gridlines? (obviously this isn't the data I'm using, these graphs are rediculous, but just can't get gridlines) (SAS 9.4 M3)
proc template;
define statgraph quadGraphs;
dynamic _X1 _X2 _X3 _X4 _Y1 _Y2 _Y3 _Y4 _group _mtrc;
begingraph;
layout lattice / columns=2;
rowaxes;
rowaxis / griddisplay=on;
endrowaxes;
columnaxes;
columnaxis / griddisplay=on;* linearopts=(minorgrid=true TICKVALUESEQUENCE=(start=0 end=600 increment=6));
endcolumnaxes;
/*upper left*/
seriesplot x=_X1 y=_Y1 / group=_group yaxis=y
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
/*upper right*/
seriesplot x=_X2 y=_Y2 / group=_group yaxis=y
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
/*lower left*/
seriesplot x=_X3 y=_Y3 / group=_group yaxis=y
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
/*lower right*/
seriesplot x=_X4 y=_Y4 / group=_group yaxis=y
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
endlayout;
endgraph;
end;/*define statgraph*/
run;
proc sgrender data=sashelp.class template=quadgraphs;
dynamic _Y1="age"
_Y2="sex"
_Y3="height"
_Y4="weight"
_X1="age"
_X2="age"
_X3="age"
_X4="age"
_group="age";
run;
Sorry, I misunderstood. Get rid of the DISPLAYDSECONDARY options and add an addition COLUMNAXIS statement:
columnaxes;
columnaxis / griddisplay=on;
columnaxis / griddisplay=on;
endcolumnaxes;
ROW and COLUMNAXIS blocks are used with ROWDATARANGE and COLUMNDATARANGE of UNION or UNIONALL. You have not specified these options, as you do not want common external axes.
In that case, use LAYOUT OVERLAY for each cell, and add the GRIDDISPLAY option for each axis for each cell.
I made one tweak to the example from the SAS documentation, what would need to change here for the second row of graphs to look like the first?
proc template;
define statgraph y2axis;
begingraph;
layout lattice / columns=2 columngutter=10
rowdatarange=union row2datarange=union ;
rowaxes;
rowaxis / griddisplay=on;
endrowaxes;
row2axes;
rowaxis;
endrow2axes;
layout overlay;
histogram height / scale=count yaxis=y2 ;
histogram height / scale=percent yaxis=y ;
densityplot height / normal();
endlayout;
layout overlay;
histogram weight / scale=count yaxis=y2 ;
histogram weight / scale=percent yaxis=y ;
densityplot weight / normal();
endlayout;
layout overlay;/*repeating the two above to get a second row of graphs*/
histogram height / scale=count yaxis=y2 ;
histogram height / scale=percent yaxis=y ;
densityplot height / normal();
endlayout;
layout overlay;
histogram weight / scale=count yaxis=y2 ;
histogram weight / scale=percent yaxis=y ;
densityplot weight / normal();
endlayout;
endlayout;
endgraph;
end;
proc sgrender data=sashelp.class template=y2axis;
run;
Remove the ROW/ROW2 axis blocks and add this to every layout overlay:
layout overlay / yaxisopt=(giddisplay=on);
I'm guessing its because I'm not doing a union on the axes, but due to the scale of the data, I don't want to union the axes. We want to compare the shape, but the axes need to be free.
Other thoughts? Can I do options on the axes inside each cell?
Yes. See my previous note.
Thanks all, I was missing the power of having layout overlay INSIDE the layout gridded. Gridded can sync up my x axis, and then I just have to repeat the y axis options I want on each of the four layout overlay statements within.
OK, I'm so close now, but I'm still not getting the x axes options on the right hand column matching the ones in the left hand column even thought they are all the same and I do want them to match.
proc template;
define statgraph quadGraphs;
dynamic _X1 _X2 _X3 _X4 _Y1 _Y2 _Y3 _Y4 _group _mtrc;
begingraph;
layout lattice / columns=2 columndatarange=unionall;
columnaxes;
columnaxis / griddisplay=on;* linearopts=(minorgrid=true TICKVALUESEQUENCE=(start=0 end=600 increment=6));
endcolumnaxes;
/*upper left*/
layout overlay / yaxisopts=(griddisplay=on);
seriesplot x=_X1 y=_Y1 / group=_group
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
endlayout;
/*upper right*/
layout overlay / yaxisopts=(griddisplay=on);
seriesplot x=_X2 y=_Y2 / group=_group
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
endlayout;
/*lower left*/
layout overlay / yaxisopts=(griddisplay=on);
seriesplot x=_X3 y=_Y3 / group=_group
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
endlayout;
/*lower right*/
layout overlay / yaxisopts=(griddisplay=on);
seriesplot x=_X4 y=_Y4 / group=_group
lineattrs=(pattern=solid)
colormodel=(CXFEBABC CXCD040B)
colorresponse=_group;
endlayout;
endlayout;
endgraph;
end;/*define statgraph*/
run
proc sgrender data=sashelp.class template=quadgraphs;
dynamic _Y1="age"
_Y2="sex"
_Y3="height"
_Y4="weight"
_X1="age" _X2="age" _X3="age" _X4="age"
_group="age";
run;
Inside each of your yaxisopts=(), add:
displaysecondary=standard
Sorry, I misunderstood. Get rid of the DISPLAYDSECONDARY options and add an addition COLUMNAXIS statement:
columnaxes;
columnaxis / griddisplay=on;
columnaxis / griddisplay=on;
endcolumnaxes;
How do I get the x axis to appear at the bottom of the graph on the right?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.