Hi All,
I am using SAS 9.4 to generate a Heatmap plot through SAS GTL code and want to control the size of boxes/tiles.
Please let me know options/statement to for the same.
%macro RandBetween(min, max);
(&min + floor((1+&max-&min)*rand("uniform")))
%mend;
data test (drop=i);
do emp = 1 to 7 ;
do i = '01JAN2017'd to '31DEC2017'd;
date=i;
value = %RandBetween(0, 100);
day = day (date);
weekday = weekday (date);
week = week (date);
month =month (date);
format date Date7.;
output ;
end;end;
run;
proc sort data = test;
by emp week month ;
run;
proc univariate data = test ;
by emp week month;
var value ;
output out=teststat mean=mean1 ;
run;
data teststat1;
set teststat;
if mean1 <= 0 then cat = 0;
else if 0<mean1 <= 25 then cat = 1;
else if 25 < mean1 <=50 then cat = 2;
else if 50 < mean1 <= 75 then cat = 3;
else if 75 < mean1 <= 100 then cat = 4;
run;
proc template;
define statgraph heatmap;
begingraph / designheight=150 designwidth=1000 pad=0;
rangeattrmap name="rmap";
range min - max / rangecolormodel=( darkred red yellow green darkgreen);
endrangeattrmap;
rangeattrvar attrmap="rmap" var=cat attrvar=cat;
layout overlay / yaxisopts=(offsetmin=0.02 display=(ticks tickvalues line) tickvalueattrs=(size=8))
xaxisopts =(offsetmin=0.02 display=(ticks tickvalues line)
linearopts=( viewmin=1 viewmax=54 tickvaluelist=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53))
tickvalueattrs=(size=3));
heatmapparm x=week y=emp colorresponse=cat / name="heatmap" xgap=0 ygap=0 display=(fill outline) outlineattrs=(color=black);
continuouslegend "heatmap" / valueattrs=(size=8) ;
endlayout;
endgraph;
end;
run;
proc sgrender data=teststat1 template=heatmap; run;
I have attached the output.
Thank you in advance
Change your design height and width.
begingraph / designheight=150 designwidth=1000 pad=0;
Hi Warren,
Thank you for your suggestion.
I changed the design height and width in code and it's changing the boxes/tiles but making graph bigger. My aim to keep graph's dimension as it is and at same time want to change the boxes/size without changing the dimension of graph. For example: keep the 53 boxes and just change the box size (horizontal rectangle) with out changing the graph dimension.
In attached output,I want to keep the same symbol/rectangle boxes and just want to reduce the size of it.
Then leave the design sizes alone and change the offsetmin and offsetmax in your x and y axis options.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.