BookmarkSubscribeRSS Feed
hellohere
Pyrite | Level 9

I have 500 observations, each of which has two measurements [offmm_ind and delta].

The dataset is attached below. 

 

How to generate 2D histogram/heatmap?!  Thanks,

 

 

4 REPLIES 4
Quentin
Super User

https://www.google.com/search?q=sas+heatmap

The Boston Area SAS Users Group is hosting free webinars!

Register now at https://www.basug.org/events.
sbxkoenk
SAS Super FREQ

Google search :

  • heatmap site:blogs.sas.com
  • heatmap site:communities.sas.com
  • heatmap site:support.sas.com

You can add the term "density" in the Google search if you wish.

 

See also :

Graphics Samples Output Gallery

https://support.sas.com/en/knowledge-base/graph-samples-gallery.html

 

Cheers,

Koen

Rick_SAS
SAS Super FREQ

There are two ways to deal with data like this:
1) Create a scatter plot and use semi-transparent markers to show regions where many observations are overplotted

2) Use a heat map to bin the markers onto a 2-D grid, then display the frequency of observations in each cell/bin.

You asked for (2), so here it is:

libname myLib "C:\Users\frwick\Downloads";
title "Frequency of Observations in 2-D Bins";
proc sgplot data=MyLib.Have;
heatmap x=offmm_ind y=delta;
run;

Rick_SAS_0-1788960246334.pngRick_SAS_0-1788960246334.png

For more ways to visualize the density of bivariate data, see
https://blogs.sas.com/content/iml/2019/09/18/visualize-density-bivariate-data.html 

DanH_sas
SAS Super FREQ

For frequency-based heat maps, you might want to favor two-color ramps instead of three-color ramps. Using @Rick_SAS 's program with the COLORMODEL option:

title "Frequency of Observations in 2-D Bins";
proc sgplot data=MyLib.Have;
heatmap x=offmm_ind y=delta / colormodel=twocolorramp;
run;

SGPlot.pngSGPlot.png

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 153 views
  • 3 likes
  • 5 in conversation