BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
josuerodrigues
Calcite | Level 5

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:

 

proc sgpanel data=Tabela_modelo noautolegend; 
where Variavel in ("C_stock" "N_stock");
panelby Variavel / columns=2 novarname spacing=10 onepanel uniscale=row ;
styleattrs datacolors=(CX08306B CX08519C CX2171B5 CX4292C6 CX6BAED6 CX9ECAE1);
vbarparm category=Cover_crop response=Estimate /  group=Cover_crop groupdisplay=cluster;
colaxis display=(nolabel novalues);
rowaxis label="Estimate" ;
run;
josuerodrigues_0-1774636975139.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

屏幕截图 2026-03-29 145430.png

View solution in original post

1 REPLY 1
Ksharp
Super User

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;

屏幕截图 2026-03-29 145430.png

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 410 views
  • 3 likes
  • 2 in conversation