0

I'm trying to convert 3 vairables into a matrix, for expample if you have the following:

(CHAR) (char) (num)

Var1 Var2 Var3

A B 1

C D 2

E F 3

A D 4

A F 5

C B 6

C F 7

E B 8

E D 9

Any ideas on how to convert the above three variables into this form of matrix below and my goal is to construct a heatmap using this matix

B   D   F

A 1 4 5

C 6 2 7

E 8 9 3

Can anyone help me do this in SAS, either using SAS/IML or other Procedure? Thanks!

Heman
  • 3
  • 2
  • I'd look at the articles on the Do Loop, such as in [this search](http://blogs.sas.com/content/iml/tag/heat-maps/), for information about heat maps in IML. Rick has all sorts of good options. – Joe Jan 08 '15 at 15:10

2 Answers2

1

Assuming you are using a recent version of SAS/IML (13.1 or later), use the HEATMAPCONT or HEATMAPDISC call:

proc iml;
m = {1 4 5,
     6 2 7,
     8 9 3};
call heatmapcont(m) xvalues={B D F} yvalues={A C E};

For details, see Creating heat maps in SAS/IML

Rick
  • 1,210
  • 6
  • 11
0

It will be better if you post your code first then ask questions.

I think proc transpose is the fastest solution.

data _t1;
input var1 $ var2 $ var3 5.;
cards;
A B 1 
C D 2
E F 3
A D 4
A F 5
C B 6
C F 7
E B 8
E D 9
run;

proc sort data=_t1;by var1;run;

proc transpose data=_t1 out=_t2(drop=_name_ rename=(var1=HereUpToYou));
by var1;
var var3;
id var2;
run;
Lovnlust
  • 1,507
  • 3
  • 29
  • 53