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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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