Published on :
Reporting SASHELP

Generating Heatmaps with SGPLOT and SGPANEL

This code is also available in: Deutsch Español Français
The script uses `PROC SGPLOT` for an overall heatmap and `PROC SGPANEL` to generate separate heatmaps by the 'sex' variable. It also configures ODS GRAPHICS options to control the appearance and format of output images. Part of the code is commented, showing examples of heatmaps with a color variable ('height').
Data Analysis

Type : SASHELP


The data comes from the SASHELP library, specifically from the 'heart' dataset, which is an example dataset provided by SAS.

1 Code Block
ODS Configuration
Explanation :
This block configures the ODS output system to direct graphics to a specific path (`gpath`) and defines global graphics options such as image size, output format (JPEG), and image name.
Copied!
1ods listing gpath="/home/nicolasdupont0/resources_github/Graph/Correlation/img" image_dpi=200;
2 
3ods graphics /
4 reset = all attrpriority=color border = no width=600px height=400px
5 imagename = "heatmap2_1" imagefmt = jpeg outputfmt = jpeg antialiasmax = 10000;
2 Code Block
PROC SGPLOT
Explanation :
Uses the `SGPLOT` procedure to generate a heatmap. The 'weight' and 'cholesterol' variables from the SASHELP.HEART dataset are used for the X and Y axes respectively, showing the density of observations at these intersections.
Copied!
1 
2PROC SGPLOT
3DATA=sashelp.heart;
4heatmap x=weight y=cholesterol;
5RUN;
6 
3 Code Block
ODS Configuration
Explanation :
This block resets and reconfigures ODS GRAPHICS options for the second heatmap, specifying a new image name.
Copied!
1ods graphics /
2reset = all attrpriority=color border = no width=600px height=400px
3imagename = "heatmap2_2" imagefmt = jpeg outputfmt = jpeg antialiasmax = 10000;
4 
4 Code Block
PROC SGPANEL
Explanation :
Uses the `SGPANEL` procedure to create separate heatmaps for each category of the 'sex' variable. This allows for easy comparison of 'weight' and 'cholesterol' distributions between groups.
Copied!
1PROC SGPANEL DATA=sashelp.heart;
2 panelby sex;
3 heatmap x=weight y=cholesterol;
4RUN;
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.
Copyright Info : Last update : 06/11/2017 ; Author(s) : Nicolas Dupont ; Contributor(s) : ; On SAS Studio 9.4M4 onDemand