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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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