Data visualization with SAS programming

Different x-axes in different rows of a data lattice / panel plot

Reply
Contributor
Posts: 25

Different x-axes in different rows of a data lattice / panel plot

I want to display some data in a 2 row by 3 column lattice (for various layout reasons for the report into which it will go 3 by 2 is not an option), but the issue is that the data on one row is on a very different order of magnitude than on the other row. Thus, in order to see bettter what is going on in each row, it would be very helpful to have different x-axes on each row.

 

To illustrate the situation, I have inserted a minmal working example below (SAS code and generated plot).

 

PROC SGPANEL does not appear to have an option to have different x-axis for each row (only different y-axes: with uniscale=column). Do I have to figure out GTL to do this or can one somehow get PROC SGPANEL to do this?

 

I made my first attempts at GTL and managed to re-produce what PROC SGPANEL does with a "layout datalattice rowvar=row columnvar=column" layout, but that does not seem to offer the option of different x-axes for different rows, either, or does it? If there's such an option that would save me a lot of work, so I would love to hear it, if this is possible.

 

If I have to switch to a "layout lattice" (which I assume should be able to do what I want), is there some easy way (or good advice) on how to get my code to work with that layout (e.g. how to put data into different lattice cells according to the row/column variables)? A link to a good example would probably already help me a lot.

SGPanel example.jpg

 

data test;
  do row=1 to 2;
  do column=1 to 3;
    do record=1 to 1000;
	x=row*1000+rannor(1234);
    y=x+rannor(1234);
	output;
	end;
  end;
  end;
run;
proc sgpanel data=test;
  panelby row column / rows=2 columns=3 uniscale=column;
  scatter x=x y=y;
run;


Here is my GTL attempt:

proc template;
define statgraph example1;
  begingraph;    
    layout datalattice rowvar=row columnvar=column / ROWDATARANGE=UNION;
        layout prototype ;
        ScatterPlot X=x Y=y / primary=true;
      endlayout;
    endlayout;
  endgraph;
end;
run;
proc sgrender data=test template=example1;  
run;
Ask a Question
Discussion stats
  • 0 replies
  • 251 views
  • 0 likes
  • 1 in conversation