Data visualization with SAS programming

Proc template lattice layout gridline issue

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

Proc template lattice layout gridline issue

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;

 


Accepted Solutions
Solution
‎06-03-2016 11:49 AM
SAS Super FREQ
Posts: 864

Re: Proc template lattice layout gridline issue

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


All Replies
SAS Super FREQ
Posts: 1,044

Re: Proc template lattice layout gridline issue

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.

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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;

SAS Super FREQ
Posts: 864

Re: Proc template lattice layout gridline issue

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

 

layout overlay / yaxisopt=(giddisplay=on);

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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?

SAS Super FREQ
Posts: 1,044

Re: Proc template lattice layout gridline issue

Yes.  See my previous note.

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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.

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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;

 

SAS Super FREQ
Posts: 864

Re: Proc template lattice layout gridline issue

Inside each of your yaxisopts=(), add:

 

displaysecondary=standard

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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
Solution
‎06-03-2016 11:49 AM
SAS Super FREQ
Posts: 864

Re: Proc template lattice layout gridline issue

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

 

columnaxes;

            columnaxis / griddisplay=on;

            columnaxis / griddisplay=on;

endcolumnaxes;

Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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! Smiley Happy
Contributor
Posts: 26

Re: Proc template lattice layout gridline issue

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

Attachment
Post a Question
Discussion Stats
  • 12 replies
  • 474 views
  • 4 likes
  • 3 in conversation