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!
%let gpath='.'; /*--Put your Folder Name here--*/
%let dpi=300;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
1
%let gpath='.'; /*--Put your Folder Name here--*/
2
%let dpi=300;
3
ods html close;
4
ods 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!
ods graphics / reset attrpriority=color width=4in height=3in imagename='2_2_1_Panel';
title 'Cholesterol by Systolic';
proc sgpanel data=sashelp.heart(where=(ageatstart > 45 and weight_status ne 'Underweight')) noautolegend;
panelby sex weight_status / layout=panel novarname headerattrs=(size=5);
scatter x=cholesterol y=systolic / markerattrs=graphdata1(symbol=circlefilled) transparency=0.7;
reg x=cholesterol y=systolic / degree=2 nomarkers;
run;
title;
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!
ods graphics / reset attrpriority=color width=4in height=3in imagename='2_2_2_Lattice';
title 'Cholesterol by Systolic';
proc sgpanel data=sashelp.heart(where=(ageatstart > 45 and weight_status ne 'Underweight')) noautolegend;
panelby sex weight_status / layout=lattice novarname;
scatter x=cholesterol y=systolic / markerattrs=(symbol=circlefilled) transparency=0.7;
reg x=cholesterol y=systolic / degree=2 nomarkers;
run;
title;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.