BookmarkSubscribeRSS Feed
Obsidian | Level 7

With SGPanel, I'm creating two heatmaps arranged in a single column. The y-axis variable for the two heatmaps is discrete, and this variable has more distinct values in the top heatmap (i.e., the top panel) than in the bottom heatmap. Thus, in the PANELBY statement I'm using the PROPORTIONAL and UNISCALE=COLUMN options to scale the panels so that the y-axis tick spacing is the same in both panels. See Figure 1 below for a dummy example using the dataset. Notice that the top panel is taller to make room for the greater number of distinct y-axis values, and the colored cells of the heatmaps are the same size between the panels.


The problem is I also want an axistable on the x-axis (i.e., a COLAXISTABLE), but adding this messes up the proportional spacing of the panels. See Figure 2 where, with the axistable, the colored cells in the top heatmap are taller than those in the bottom heatmap.


Cars heatmap figures 1 and 2.png


Any thoughts on how to fix Figure 2, so I can have my axistable and maintain the proportional spacing?


See my code below to generate Figures 1 and 2. I ran this in SAS Studio using SAS version 9.04.01M6P11072018.


data cars;
	where origin = 'Asia' or (origin = 'Europe' and type in ('Sedan' 'Wagon'));

ods graphics / width=4in height=6in border;
ods layout gridded advance=table columns=2;

title 'Fig. 1: Y-axis spacing is consistent between the two panels';
proc sgpanel data=cars;
	panelby origin / layout=rowlattice uniscale=column proportional spacing=5;
	heatmap x=drivetrain y=type / outline;
	rowaxis discreteorder=unformatted;

title 'Fig. 2: Y-axis spacing is NOT consistent between the two panels when using COLAXISTABLE';
proc sgpanel data=cars;
	panelby origin / layout=rowlattice uniscale=column proportional spacing=5;
	heatmap x=drivetrain y=type / outline;
	rowaxis discreteorder=unformatted;
	colaxistable msrp weight / stat=mean separator;

ods layout end;
Super User
Could you use " uniscale=row " ?
Obsidian | Level 7
Hi Ksharp, I don't think using "uniscale=row" helps for my use case. It makes the top and bottom panels have the same 6 y-axis tick values (Hybrid, SUV, Sedan, Sports, Truck, Wagon) but I want the bottom panel to have just the two values that appear in the data (Sedan and Wagon).

I probably should have originally said, for my real use case, each panel is a treatment group, each row on the y-axis is a patient, and each column on the x-axis is a clinic visit. The heatmap colors show which visits each patient attended along with what type of visit it was (i.e., whether a certain procedure was performed). The colaxistable tallies the number of patients at each visit, both overall and by visit type. In this use case, there is actually no overlap in y-axis values between the panels, since each patient belongs to only one treatment group.


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2 in conversation