Published on :
Reporting SASHELP

SGPANEL Layout Comparison: Panel vs Lattice

This code is also available in: Deutsch Español Français
This program illustrates the use of the SGPANEL procedure to visualize multidimensional data from the 'sashelp.heart' table. It first configures the graphical output environment (ODS). Then, it produces two distinct graphs: the first uses a panel layout ('layout=panel') and the second a lattice layout ('layout=lattice'). Both graphs superimpose a scatter plot and a quadratic regression curve.
Data Analysis

Type : SASHELP


Using the SASHELP.HEART example table. A filter is applied to keep only patients over 45 years old and exclude those who are 'Underweight'.

1 Code Block
CONFIGURATION
Explanation :
Initialization of macro variables for the path and resolution, and configuration of the ODS Listing destination for image export.
Copied!
1%let gpath='.'; /*--Put your Folder Name here--*/
2%let dpi=300;
3ods html close;
4ods listing gpath=&gpath image_dpi=&dpi;
2 Code Block
PROC SGPANEL
Explanation :
Generation of a panel graph (layout=panel) crossing the variables 'sex' and 'weight_status'. The graph shows the correlation between cholesterol and systolic pressure via a scatter plot and a 2nd degree polynomial regression.
Copied!
1ods graphics / reset attrpriority=color width=4in height=3in imagename='2_2_1_Panel';
2title 'Cholesterol by Systolic';
3PROC SGPANEL DATA=sashelp.heart(where=(ageatstart > 45 and weight_status ne 'Underweight')) noautolegend;
4panelby sex weight_status / layout=panel novarname headerattrs=(size=5);
5 scatter x=cholesterol y=systolic / markerattrs=graphdata1(symbol=circlefilled) transparency=0.7;
6 reg x=cholesterol y=systolic / degree=2 nomarkers;
7RUN;
8title;
3 Code Block
PROC SGPANEL
Explanation :
Generation of a graph similar to the previous one but using a lattice layout (layout=lattice) to align the panels in strict rows and columns.
Copied!
1ods graphics / reset attrpriority=color width=4in height=3in imagename='2_2_2_Lattice';
2title 'Cholesterol by Systolic';
3PROC SGPANEL DATA=sashelp.heart(where=(ageatstart > 45 and weight_status ne 'Underweight')) noautolegend;
4panelby sex weight_status / layout=lattice novarname;
5 scatter x=cholesterol y=systolic / markerattrs=(symbol=circlefilled) transparency=0.7;
6 reg x=cholesterol y=systolic / degree=2 nomarkers;
7RUN;
8title;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.