SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
CodingDiSASter
Fluorite | Level 6

I've been learning about SAS in a course and I've been looking for ways to apply it to my job in analytical chemistry. Is it possible to use SAS to produce heat maps? It looks like SAS will be much more direct in figure customization compared to MPP. If I have data that looks like this:

 

  Sample_1Sample_2Sample_3Sample_4Sample_5Sample_6
  ControlControlControlTreatment_ATreatment_ATreatment_A
Compound_1Pathway_10.310.980.020.960.810.59
Compound_2Pathway_10.850.210.910.410.010.86
Compound_3Pathway_10.580.980.150.460.020.62
Compound_4Pathway_10.040.590.220.170.030.86
Compound_5Pathway_10.400.890.440.840.350.21
Compound_6Pathway_10.460.130.340.970.290.21
Compound_7Pathway_20.820.420.710.290.820.92
Compound_8Pathway_20.530.780.160.250.060.56
Compound_9Pathway_20.670.600.940.150.400.53
Compound_10Pathway_20.400.420.890.610.940.63
Compound_11Pathway_20.480.860.110.690.440.09
Compound_12Pathway_20.290.640.630.590.870.48

 

I can format the data however I'd like in Excell before I bring it into SAS if it makes it easier. Right now some of the lab members are running ANOVAs by cutting and pasting code into Graphpad so I've already got some ideas for using SAS to streamline things but I was wondering if it was possible to take it a step further.

 

Thanks!

2 REPLIES 2
ballardw
Super User

For most things in SAS you would be better off having a separate variable such as Sample_number, and another variable that indicates Control and Treatment_a and assuming the body of the numbers are measuring the same property then one variable for the measurement.

 

Heatmaps use 2 variables for the dimensions. From your example I am not sure what makes most sense for the dimensions as each  segment needs one value from each dimension for location and optionally a value to assign a weight or frequency for setting the color of the blocks.

 

Here is a not terribly useful but simple example using a data set you should have available.

proc sgplot data=sashelp.class;
  heatmap x=height y=weight /
          nxbins=4 nybins=3
          showxbins showybins
          freq=age
  ;
run;

The above code uses the given data set with the student height as the xaxis, student weight as yaxis,

nxbins and nybins set maximum number of bins to group the values of height and weight and the Showxbins and Showybins will have axis tick marks at the (may be approximate) center of the bin. the Freq=Age treats each record as between 11 and 16 records just to use the feature. Remove that bit and see the difference of appearance. There will be gradient on the right of the graph indicating the value the colors of the bins in heatmap indicate.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 2 replies
  • 932 views
  • 1 like
  • 3 in conversation