BookmarkSubscribeRSS Feed
AmitKB
Fluorite | Level 6
Hi,
Thanks for the help.

I am trying to create a vertical stacked column chart using gghart. the subgroup variable 'type' has 2 values A and B. I want B to be on top of stack and A on bottom. Basically I want to control order of stacking.

Data;
input year type amount;
2005 A 1000
2005 B 35
2006 A 345
2006 B 500

Thanks,

Amit
2 REPLIES 2
Andre
Obsidian | Level 7
Amit
A way to understand
[pre]
Data z;
input year type $ amount;
cards;
2005 A 1000
2005 B 35
2006 A 345
2006 B 500
;
run;
proc format ;
value $t "A" = "top A"
"B" = "bottom B"
;
value $inv "A" = "bottom A"
"B" = "top B"
;
run;
proc gchart data=z ;
vbar year/discrete subgroup=type sumvar=amount;
format type $t.;
run;
quit;
proc gchart data=z ;
vbar year/discrete subgroup=type sumvar=amount;
format type $inv.;
run;
quit;

[/pre]
AmitKB
Fluorite | Level 6
Thanks a lot. This is what I was looking for.

Can you tell me why it works. Is it because of the alphabets order. Bottom comes before top.

Thanks,

Amit

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 1266 views
  • 0 likes
  • 2 in conversation