BookmarkSubscribeRSS Feed
dagremu
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 sashelp.cars 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;
	set sashelp.cars;
	where origin = 'Asia' or (origin = 'Europe' and type in ('Sedan' 'Wagon'));
run;

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;
run;

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;
run;

ods layout end;
2 REPLIES 2
Ksharp
Super User
Could you use " uniscale=row " ?
dagremu
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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 160 views
  • 0 likes
  • 2 in conversation