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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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