Hello everyone,
I am struggling with a visualization issue in PROC SGPANEL. I want to plot two different variables (Soil Carbon Stock and Nitrogen Stock) side-by-side.
The problem is that my Carbon values are around 80 Mg/ha, while Nitrogen values are around 7 Mg/ha. Since SGPANEL forces a uniform scale for the row, my Nitrogen bars become almost invisible.
Is there any way to force independent Y-axis scales for each panel while keeping them in the same row?
Here is a snippet of my current code:
1)
Nope.
If you want "keeping them in the same row" ,then you have to plot two graph and combine them together, check this blog:
https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures...
Otherwise you should stack up these two graphics to make they have Y-Axis separatedly .
2)
An alternative way is using GTL, check PROC TEMPLATE .
proc template;
define statgraph lattice;
begingraph;
entrytitle "Car Performance Profile";
layout lattice / border=false pad=0 opaque=true
rows=1 columns=2 columngutter=3;
layout overlay;
barchart category=status1 response=value1 /yaxis=y group=status1 name="cars";
endlayout;
layout overlay;
barchart category=status2 response=value2 /yaxis=y group=status2;
endlayout;
sidebar;
discretelegend "cars";
endsidebar;
endlayout;
endgraph;
end;
run;
data Alive Dead;
set sashelp.heart(obs=200 keep=status sex weight height);
if status='Alive' then output Alive;
else output Dead;
run;
data have;
merge alive(rename=(sex=status1 weight=value1)) dead(rename=(sex=status2 height=value2));
run;
proc sgrender data=have
template=lattice;
run;
1)
Nope.
If you want "keeping them in the same row" ,then you have to plot two graph and combine them together, check this blog:
https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures...
Otherwise you should stack up these two graphics to make they have Y-Axis separatedly .
2)
An alternative way is using GTL, check PROC TEMPLATE .
proc template;
define statgraph lattice;
begingraph;
entrytitle "Car Performance Profile";
layout lattice / border=false pad=0 opaque=true
rows=1 columns=2 columngutter=3;
layout overlay;
barchart category=status1 response=value1 /yaxis=y group=status1 name="cars";
endlayout;
layout overlay;
barchart category=status2 response=value2 /yaxis=y group=status2;
endlayout;
sidebar;
discretelegend "cars";
endsidebar;
endlayout;
endgraph;
end;
run;
data Alive Dead;
set sashelp.heart(obs=200 keep=status sex weight height);
if status='Alive' then output Alive;
else output Dead;
run;
data have;
merge alive(rename=(sex=status1 weight=value1)) dead(rename=(sex=status2 height=value2));
run;
proc sgrender data=have
template=lattice;
run;
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.