BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ANWZimmerman
Obsidian | Level 7

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Sorry, I misunderstood. Get rid of the DISPLAYDSECONDARY options and add an addition COLUMNAXIS statement:

 

columnaxes;

            columnaxis / griddisplay=on;

            columnaxis / griddisplay=on;

endcolumnaxes;

View solution in original post

12 REPLIES 12
Jay54
Meteorite | Level 14

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.

ANWZimmerman
Obsidian | Level 7

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;

DanH_sas
SAS Super FREQ

Remove the ROW/ROW2 axis blocks and add this to every layout overlay:

 

layout overlay / yaxisopt=(giddisplay=on);

ANWZimmerman
Obsidian | Level 7

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?

Jay54
Meteorite | Level 14

Yes.  See my previous note.

ANWZimmerman
Obsidian | Level 7

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.

ANWZimmerman
Obsidian | Level 7

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;

 

DanH_sas
SAS Super FREQ

Inside each of your yaxisopts=(), add:

 

displaysecondary=standard

ANWZimmerman
Obsidian | Level 7
Not quite what I was looking for, that turned on the Y2 axis in all the graphs. I'm trying to get the x axis to display in the two graphs in the right column
DanH_sas
SAS Super FREQ

Sorry, I misunderstood. Get rid of the DISPLAYDSECONDARY options and add an addition COLUMNAXIS statement:

 

columnaxes;

            columnaxis / griddisplay=on;

            columnaxis / griddisplay=on;

endcolumnaxes;

ANWZimmerman
Obsidian | Level 7
Thank You!!!! That was it! I didn't realize that you could set different options for each column (and I assume each row by having a columnaxis statement for each column! 🙂
ANWZimmerman
Obsidian | Level 7

How do I get the x axis to appear at the bottom of the graph on the right?


SGRender67.png

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 2941 views
  • 4 likes
  • 3 in conversation