BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi anyone,

up to now, we have a grouped bar-graph like this:

options device=javaimg gunit=pt ftext=swissl cback=white;
pattern1 value=solid color=CX113388;
pattern2 value=solid color=CX426BB3;
legend1 across=1 frame position=(top center outside) label=none value=(justify=center);

proc gchart data=work.GrundlageGrafik;
format datum ddmmyyp10.;
vbar datum / sumvar = stapel
group = gruppe
subgroup = datum
legend = legend1
patternid = subgroup sum
raxis = axis1 maxis = axis2 gaxis = axis3;
axis1 label=none minor=none;
axis2 label=none value=(tick=1 '' tick=2 '');
axis3 label=none order=('Bis 2 Tage' '3-5 Tage' '6-8 Tage' 'Aelter 8 Tage');
run;

Datalines for work.grundlageGrafik are like this:
datum: gruppe: stapel:
'03MAY2009'd 3-5 Tage 827
'03MAY2009'd 6-8 Tage 592
'03MAY2009'd Bis 2 Tage 2824
'03MAY2009'd Aelter 8 Tage 637
'03MAY2009'd 3-5 Tage 1424
'10MAY2009'd 6-8 Tage 907
'10MAY2009'd Bis 2 Tage 1475
'10MAY2009'd Aelter 8 Tage 807

Now I should produce the same bar-graph, but the bars now stacked into 3 different parts (according to new field KZ). The colour of the stacked parts of one bar could stay all the same and the parts devided by a black or white line. Also, it's possible to have the same colour for the stacked parts, but different patterns.

Datelines for the "new" work.GrundlageGrafik are like this:
datum: gruppe: stapel KU
'03MAY2009'D 3-5 Tage 248 A
'03MAY2009'D 3-5 Tage 124 B
'03MAY2009'D 3-5 Tage 24 C
'03MAY2009'd 6-8 Tage 177 A
'03MAY2009'D 6-8 Tage 88 B
'03MAY2009'D 6-8 Tage 17 C
'03MAY2009'd Bis 2 Tage 847 A
'03MAY2009'D Bis 2 Tage 423 B
'03MAY2009'd Bis 2 Tage 84 C
'03MAY2009'd Aelter 8 Tage 191 A
'03MAY2009'D Aelter 8 Tage 95 B
'03MAY2009'd Aelter 8 Tage 19 C
'10MAY2009'd 3-5 Tage 427 A
'10MAY2009'D 3-5 Tage 213 B
'10MAY2009'd 3-5 Tage 42 C
'10MAY2009'd 6-8 Tage 27 A
'10MAY2009'd 6-8 Tage 136 B
'10MAY2009'd 6-8 Tage 27 C
'10MAY2009'd Bis 2 Tage 442 A
'10MAY2009'd Bis 2 Tage 221 B
'10MAY2009'd Bis 2 Tage 44 C
'10MAY2009'd Aelter 8 Tage 24 A
'10MAY2009'd Aelter 8 Tage 121 B
'10MAY2009'd Aelter 8 Tage 24 C


Does anyone know, whether such a graph type is generally possible and if yes, how to code?

Thanks a lot for any advice!
Sonni
2 REPLIES 2
deleted_user
Not applicable
Just to make it a little bit clearer how data is structured, here is the data step to produce the new datafile. (The old datafile is very similar, there is just no column KZ)

data GrundlageGrafik;
input datum date12. gruppe $16. stapel KZ $1.;
format datum date9.;
datalines;
'03MAY2009'D 3-5 Tage 248 A
'03MAY2009'D 3-5 Tage 124 B
'03MAY2009'D 3-5 Tage 24 C
'03MAY2009'd 6-8 Tage 177 A
'03MAY2009'D 6-8 Tage 88 B
'03MAY2009'D 6-8 Tage 17 C
'03MAY2009'd Bis 2 Tage 847 A
'03MAY2009'D Bis 2 Tage 423 B
'03MAY2009'd Bis 2 Tage 84 C
'03MAY2009'd Aelter 8 Tage 191 A
'03MAY2009'D Aelter 8 Tage 95 B
'03MAY2009'd Aelter 8 Tage 19 C
'10MAY2009'd 3-5 Tage 427 A
'10MAY2009'D 3-5 Tage 213 B
'10MAY2009'd 3-5 Tage 42 C
'10MAY2009'd 6-8 Tage 27 A
'10MAY2009'd 6-8 Tage 136 B
'10MAY2009'd 6-8 Tage 27 C
'10MAY2009'd Bis 2 Tage 442 A
'10MAY2009'd Bis 2 Tage 221 B
'10MAY2009'd Bis 2 Tage 44 C
'10MAY2009'd Aelter 8 Tage 24 A
'10MAY2009'd Aelter 8 Tage 121 B
'10MAY2009'd Aelter 8 Tage 24 C
;
run;
DanielSantos
Barite | Level 11
Not sure about what your aiming to do, but, to stack KZ, you should use the SUBGROUP options. The following modification will suffice.

proc gchart data=work.GrundlageGrafik;
format datum ddmmyyp10.;
vbar datum / sumvar = stapel
group = gruppe
subgroup = KZ /* datum */
legend = legend1
patternid = subgroup sum
raxis = axis1 maxis = axis2 gaxis = axis3;
axis1 label=none minor=none;
axis2 label=none value=(tick=1 '' tick=2 '');
axis3 label=none order=('Bis 2 Tage' '3-5 Tage' '6-8 Tage' 'Aelter 8 Tage');
run;

GROUP, will combine categories and SUBGROUP will stack values.

Is this what you want?

Check the online documentation for SAS Graph in particular for the gchart procedure:
http://support.sas.com/documentation/onlinedoc/graph/index.html

And give a look at the sample gallery:
http://support.sas.com/sassamples/graphgallery/index.html

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

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